Help: SQL syntax error???

  • Thread starter Thread starter VB Programmer
  • Start date Start date
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!
 
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.
 
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!
 
Back
Top