SnoopFrogg
MIS
I am attempting to write to an Access database table using this line of code:
[purple]insertIntoDB("INSERT INTO Mandrills(Time1, Animal, Loc, Eat, For, Soc, Agg, Ster, Act, View, Other, Location, ConMan, Indirect, Other2, Initials, Comments, NumObsAM, NumObsPM) VALUES('test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2')");[/purple]
When I execute my program, I receive the following error:
[purple]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 CopyFile.Form1.insertIntoDB(String sqlInsertStatement)[/purple]
I have run this query successfully in Access (I verified by seeing the added rows in my table).
I have executed the following similar query in Visual C# successfully (I verified the added rows, as well). The syntax for this query and the previous is similar so I'm not sure what I'm missing:
[purple]insertIntoDB("INSERT INTO test(test1, test2) VALUES('1', '2')");[/purple]
Any thoughts? The only cause I can think of is a possible length limitation for C# SQL statements.
[purple]insertIntoDB("INSERT INTO Mandrills(Time1, Animal, Loc, Eat, For, Soc, Agg, Ster, Act, View, Other, Location, ConMan, Indirect, Other2, Initials, Comments, NumObsAM, NumObsPM) VALUES('test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2', 'test2')");[/purple]
When I execute my program, I receive the following error:
[purple]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 CopyFile.Form1.insertIntoDB(String sqlInsertStatement)[/purple]
I have run this query successfully in Access (I verified by seeing the added rows in my table).
I have executed the following similar query in Visual C# successfully (I verified the added rows, as well). The syntax for this query and the previous is similar so I'm not sure what I'm missing:
[purple]insertIntoDB("INSERT INTO test(test1, test2) VALUES('1', '2')");[/purple]
Any thoughts? The only cause I can think of is a possible length limitation for C# SQL statements.