Reputation: 452
using (IDbConnection dbConnection = openConnection)
{
string uQuery = "INSERT INTO User (Email, UserName, Password)"
+ " VALUES(@Email, @UserName, @Password)";
dbConnection.Open();
dbConnection.Execute(uQuery, User);
}
I'm getting a sql exception: Incorrect syntax near the keyword 'User'. on the db.Connection.Execute statement. I get the same error even if I omit the User parameter of the statement. Am I doing the insert wrong?
Upvotes: 2
Views: 524
Reputation: 7254
User is a reserved work in SQL server. Wrap User between brackets as [User]
to solve.
Reference Reserved Keywords in SQL Server: https://msdn.microsoft.com/en-us/library/ms189822.aspx
Hope this helps.
Upvotes: 5