I always get an invalid INSERT INTO exception
// Create the DataSet object
DataSet oDS = new DataSet();
OleDbConnection conn = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=domotica7.mdb");
conn.Open();
// Create the DataTable
OleDbDataAdapter oOrdersDataAdapter = new OleDbDataAdapter(new
OleDbCommand("SELECT * FROM InOut", conn));
OleDbCommandBuilder oOrdersCmdBuilder = new
OleDbCommandBuilder(oOrdersDataAdapter);
oOrdersDataAdapter.FillSchema(oDS, SchemaType.Source);
DataTable pTable = oDS.Tables["Table"];
pTable.TableName = "InOut";
// Insert the Data
DataRow oOrderRow = oDS.Tables["InOut"].NewRow();
oOrderRow["Modulenaam"]="testmodule";
oOrderRow["Omschrijving"] = "informatie";
oOrderRow["SubAdres"] = 123;
oOrderRow["Zone"] = "badkamer";
oDS.Tables["InOut"].Rows.Add(oOrderRow);
//this fails
oOrdersDataAdapter.Update(oDS, "inout");
conn.Close();
"Miki Watts" <mi*****@netvision.net.il> wrote in message
news:KM********************@giganews.com...
"Sagaert Johan" <RE*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... I need some example
I have a dataset populeted through a dataadapter fill method
i can add rows to my dataset , but i have an exception when calling the
dataadpters update method.
I already spent 7 hours to solve this, yet i still am no step further.
I might be missing something around the Updatecommand property of the
oleDBDataAdapter.
Can someone point me to an example or more information ?
There are two things i can think of (at least, that i ran into them
myself): 1. You have an autonumber column in the table, but the MissingSchemaAction
property in the data adapter is set to Add, but not AddWithKey.
2. Your table comes from a query, so it's not possible to update the
tables that the data came from.
Miki