I am trying to insert a new row into my database using an INSERT INTO SQL query. I am not sure what I am doing wrong as I am not the more experienced programmer.
I am trying to add the integer value 1 to the column Question Type when the button is pressed. My primary key increments automatically so that shouldn't be a problem as all of the other columns can be NULL.
INSERT INTO dbo.Questions (Question Type)
VALUES (1)
When I press OK to this query an error displays saying :
An error occurred while trying to create the parameterized query:
Error in list of function arguments: 'Type' not recognized. Incomplete parameters or column list. Unable to parse query text.
This is the code for the table I am trying to add to:
CREATE TABLE [dbo].[Questions] (
[QuestionID] INT IDENTITY (1, 1) NOT NULL,
[Actual answer] NVARCHAR (50) NULL,
[Question Space] NVARCHAR (50) NULL,
[Question Type] INT NULL,
PRIMARY KEY CLUSTERED ([QuestionID] ASC)
);
Try this.. If the column name has White Space, then the entire column name should be enclosed using Square Brackets ([]).
INSERT INTO dbo.Questions ([Question Type])
VALUES (1)
This is for SQL server... if it is MySQL then use ("") or (``)
you not allowed to use spaces between column names. either use identifier with double quotes or square braces."" OR []
INSERT INTO dbo.Questions ("Question Type")
VALUES (1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With