I am having a small problem I am trying to add data to my database on my local SQL Server. I inserted this Try...Catch... Statement in my code to find the problem.
Code:
Code'Execute the SqlCommand object to insert the new data...
Try
objCommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(Err.Description)
End Try
And it gives me an error message saying Incorrect Syntax near 'nvarchar' must declare the variable @Annual
Code:
'set the SqlCommand object properties...
objCommand.Connection = SqlConnection1
objCommand.CommandText = "INSERT INTO Demo " & _
"(Address, [Annual Income], [Case Number], [Estimated Cost], [First Name], ID, [Last Name], Status)" & _
"VALUES (@Address, @Annual Income, @Case Number, @Estimated Cost, @First Name, @ID, @Last Name, @Status);":
To my understanding if I put a @before my column name it acts like a placeholder for data that will be inserted by the SqlParameter objects in the parameters collection?
So if anyone can see the problem please help me out.