OldDbCommandBuilder not generating commands

K

Kenneth Baltrinic

I have created a dataset wrapper class that manages the data adapters needed
to fetch and update various tables within a dataset. In this class is the
following method which works fine in several implementations but not in my
current one. Specifically the command builder is not doing anything and
leaving me with undefined action queries. Does anyone know of a cause for
this? The select query is in place and executes fine (i replaced the
da.Update() with a da.Fill() in the below code and it worked without error.)

I get an "Invalid Insert command" error when this code runs and inspecting
the da object reveals that the command is undefined.

protected void rUpdateTable(string sTableName)
{
//Get the stored data adapter from a hash table
OleDbDataAdapter da = (OleDbDataAdapter)pcDataAddapters[sTableName];

OleDbCommandBuilder cb = new OleDbCommandBuilder(da);

// Include an event to fill in the Autonumber value.
OleDbRowUpdatedEventHandler eh = new
OleDbRowUpdatedEventHandler(pOnRowUpdated);
da.RowUpdated += eh;

da.Update(rDataSet, sTableName);

//Unregister event after update completed
da.RowUpdated -= eh;
}

--Ken
 
K

Kenneth Baltrinic

It does. The select is very simple. Select * from tblMembers where LoginID
= 'TestMember'

The only thing I can think of that is even slightly out of the ordinary is
that currently the table is empty. The above query was actually a test to
see if 'TestMember' existed to avoid a name conflict before adding him.
Therefore the query returns no rows but it should still return the needed
meta data.

Also in case it helps, here is the connection string.
Provider=Microsoft.Jet.OleDb.4.0;Data Source=F:\server
data\wwwroot\svsc\svsc.mdb

--Ken

William Ryan said:
Doese the table have a primary key? That's a likely culprit.
Kenneth Baltrinic said:
I have created a dataset wrapper class that manages the data adapters needed
to fetch and update various tables within a dataset. In this class is the
following method which works fine in several implementations but not in my
current one. Specifically the command builder is not doing anything and
leaving me with undefined action queries. Does anyone know of a cause for
this? The select query is in place and executes fine (i replaced the
da.Update() with a da.Fill() in the below code and it worked without error.)

I get an "Invalid Insert command" error when this code runs and inspecting
the da object reveals that the command is undefined.

protected void rUpdateTable(string sTableName)
{
//Get the stored data adapter from a hash table
OleDbDataAdapter da = (OleDbDataAdapter)pcDataAddapters[sTableName];

OleDbCommandBuilder cb = new OleDbCommandBuilder(da);

// Include an event to fill in the Autonumber value.
OleDbRowUpdatedEventHandler eh = new
OleDbRowUpdatedEventHandler(pOnRowUpdated);
da.RowUpdated += eh;

da.Update(rDataSet, sTableName);

//Unregister event after update completed
da.RowUpdated -= eh;
}

--Ken
 
K

Kenneth Baltrinic

The problem was that one of the column names (password) in the table was a
reserved keyword.
--Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top