Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi.....

Given below is my code to insert data int a table : USER.

Dim myInsertQuery As String = "INSERT INTO USER   (USERID,PASSWORD)  Values('roll', 'name')"
Dim mycommand As New OdbcCommand(myInsertQuery)
  mycommand.Connection = myConnection
  mycommand.ExecuteNonQuery()


But the code is not working properly...i am getting the error message given below .....can any one suggest a solution please,thanks in advance..

'ERROR [42000] [Sybase][ODBC Driver][Adaptive Server Anywhere]
'Syntax error or access violation: near 'USER' in INTO [USER]
Posted
Updated 23-Feb-10 18:16pm
v2

When you name tables after keywords, you should put them in [].

SQL
Dim myInsertQuery As String = "INSERT INTO [USER]   (USERID,PASSWORD)  Values('roll', 'name')"
 
Share this answer
 
I think you need to rename the table that you are using.

USER is a key word in query world.
 
Share this answer
 
It is always recommended not to use keywords in the query. You must read some best practices and coding conventions from here.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900