Reputation: 6085
I am getting the error:
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'desc'.
Can anyone please help me what is the problem ?
if (IsPost && Validation.IsValid())
{
name = Request.Form["name"];
price = Request.Form["price"];
desc = Request.Form["desc"];
var db = Database.Open("mystring");
var insertCommand = "INSERT INTO CarBike (name,image,price,desc,date,userid) VALUES(@0,@1,@2,@3,@4,@5)";
db.Execute(insertCommand, name, image, price, desc, date, userid);
Response.Redirect("~/Members");
}
Upvotes: 1
Views: 144
Reputation: 102723
The problem is that desc is a keyword in SQL, so you need to write that column using square brackets:
var insertCommand = "INSERT INTO CarBike (name,image,price,[desc],date,userid) VALUES(@0,@1,@2,@3,@4,@5)";
Upvotes: 8