Never rely on the implicit column amount or order in an
INSERT
statement. Instead, define all the columns you're going to use. So the syntax should be
INSERT INTO TableName
(ColumnName, ColumnName, ...)
VALUES
(Value, Value, ...)
And the other thing is that you should always use parameters with queries. Never concatenate values directly to SQL statements. For more information have a look at
OleDbParameter Class (System.Data.OleDb)[
^]
Also you should use
using
statement to ensure that objects are properly disposed. Even though the article is written about SqlCommands, have a look at
Properly executing database operations[
^] The same principles apply to
OleDbCommand
.