Anders R
3/9/2006 7:20:00 PM
Hi,
I have a small problem with "odbccommandbuilder".
I get an exception exception = {"ERROR [07002] [Microsoft][ODBC Microsoft
Access Driver]COUNT field incorrect"}
--- START CODE ---
public void WriteDataToDatabase(DataSet ds)
{
/* --- SQL INSERT INTO Statement ---
* INSERT INTO "table_name" ("column1", "column2", ...)
* VALUES ("value1", "value2", ...)
*/
try
{
string mySelectQuery = "INSERT INTO Info (Name, Age) VALUES (?, ?)";
OdbcDataAdapter da = new OdbcDataAdapter();
da.InsertCommand = new OdbcCommand (mySelectQuery, conn);
da.SelectCommand = new OdbcCommand("select * from Info", conn);
OdbcCommandBuilder cb = new OdbcCommandBuilder(da);
//If I enables this code below, all works fine!
//da.InsertCommand = conn.CreateCommand();
//da.InsertCommand.CommandText = "insert into Info " +
// "(Name, Age) " +
// "values " +
// "(?, ?)";
//da.InsertCommand.Parameters.Add("Name", OdbcType.Char, 0, "Name");
//da.InsertCommand.Parameters.Add("Age", OdbcType.Char, 0, "Age");
//Without the OdbcCommandBuilder this line would fail, It fails
anyway :)
da.Update(ds, "Info");
}
catch (Exception exception)
{
throw exception;
}
}
--- END CODE ---
Can anyone help??
Best Regards
/Anders