Hi all,
I have written sql code to create a SQL Server CE database to be deployed on a Windows Mobile emulator using the SqlCeEngine object. The sql statements are enclosed in the form load procedure. However, when i run the program i get the following error: There was an error parsing the query [ Token line number = 1,Token line offset = 14,Token in error = User ] which references the sqlcreateTable.ExecuteNonQuery() method.
I have looked up the meaning of this SqlCeException on MSDN but no help there. Can any one explain what i may be doing wrong? Below is a snippet of code that produces the error:

sqlCreateTable.CommandText = "CREATE TABLE User(userID int PRIMARY KEY, " +
                             "username nvarchar, password nvarchar)";
[B]sqlCreateTable.ExecuteNonQuery();[/B] // produces an SqlCeException error message

Well... by looking to command text, you are creating a table named "User".

"User" is Reserved keyword of MS SQL.

Microsoft SQL Server uses reserved keywords for defining, manipulating, and accessing databases. Reserved keywords are part of the grammar of the Transact-SQL language used by SQL Server to parse and understand Transact-SQL statements and batches.

For more information refer below link:
http://msdn.microsoft.com/en-us/library/aa258313(SQL.80).aspx

Well... by looking to command text, you are creating a table named "User".

"User" is Reserved keyword of MS SQL.

Microsoft SQL Server uses reserved keywords for defining, manipulating, and accessing databases. Reserved keywords are part of the grammar of the Transact-SQL language used by SQL Server to parse and understand Transact-SQL statements and batches.

For more information refer below link:
http://msdn.microsoft.com/en-us/library/aa258313(SQL.80).aspx

Thank You. It worked. I am new to SQL Server and had no idea that 'User' was a reserved word. The post has been marked as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.