Help: SQL syntax error???

V

VB Programmer

When I run an SQL statement with ADO.NET it gives me this error:

System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32
hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at DMSI.SqlHelper.ExecuteSql(String strSql, String strCnnString) in
c:\inetpub\wwwroot\DMSI\SqlHelper.vb:line 9

When I copy/paste the SQL directly into an Access query and run it it runs
PERFECT.

Here's the SQL:

INSERT INTO
Employees(EmployeeId,TitleId,FirstName,MiddleInitial,LastName,Address,City,S
tate,Zip,CellPhone,Fax,EmailAddress,UserName,Password,RegionalDirectorId)
VALUES(8,3,'c','c','c','c','c','c','c','c','c','c','c','c',6);

Ideas?

Thanks!
 
M

Marina

I believe 'Password' is a reserved word. You shouldn't name your column with
reserved word names, as this kind of thing tends to happen.

If this is indeed the problem (you didn't actually post any of your code),
try putting Password in '[' and ']' to see if that helps.
 
V

VB Programmer

Thanks Marina!!!

Marina said:
I believe 'Password' is a reserved word. You shouldn't name your column with
reserved word names, as this kind of thing tends to happen.

If this is indeed the problem (you didn't actually post any of your code),
try putting Password in '[' and ']' to see if that helps.

VB Programmer said:
When I run an SQL statement with ADO.NET it gives me this error:

System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32
hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at DMSI.SqlHelper.ExecuteSql(String strSql, String strCnnString) in
c:\inetpub\wwwroot\DMSI\SqlHelper.vb:line 9

When I copy/paste the SQL directly into an Access query and run it it runs
PERFECT.

Here's the SQL:

INSERT INTO
Employees(EmployeeId,TitleId,FirstName,MiddleInitial,LastName,Address,City,S
tate,Zip,CellPhone,Fax,EmailAddress,UserName,Password,RegionalDirectorId)
VALUES(8,3,'c','c','c','c','c','c','c','c','c','c','c','c',6);

Ideas?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top