2
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?

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.