OleDB update command ?

  • Thread starter Thread starter Sagaert Johan
  • Start date Start date
S

Sagaert Johan

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 ?



Johan
 
Maybe posting the code that causes the error would help ? Its easier to
diagnose that way...JMHO
 
Sagaert Johan said:
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
 
I will prepare one and post it.

I am using the design time components on my form.

One of the exceptions i had said i was missing the insert command in the
oledbdataadapter.
This might be were i got stuck with.
 
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();
 
Found the cause:
one of the field names in my access MDB was the name of a .NET class keyword
..

The INSERT INTO systax error exception seriously misleaded me...
 
Back
Top