error in update command using dataadapter

N

nannu

m using this code :...........................

=======================================================================

OleDbConnection con =new OleDbConnection
(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source = C:\Documents and
Settings\ic411242\My Documents\db2.mdb");
con.Open ();

OleDbDataAdapter adp =new OleDbDataAdapter();
adp.SelectCommand = new OleDbCommand ( "select * from t1",con);

OleDbCommandBuilder cbd =new OleDbCommandBuilder (adp);
DataSet ds =new DataSet ();
adp.Fill (ds,"t1");

ds.Tables["t1"].Rows[0]["name"]="crystal";


adp.Update(ds,"t1");

con.Close ();
=======================================================================

PROBLEM :: RUNTIME ERROR --- Dynamic SQL generation for the
UpdateCommand is not supported against a SelectCommand that does not
return any key column information.

t1 = TABLE IN MY DOCUMENTS
 
M

Morten Wennevik [C# MVP]

Hi nannu,

I'm guessing your table is lacking a primary key/identity column. Without
such a column you can't use CommandBuilder to generate your update
commands. However, you can still create the update command manually.
 
N

nannu

Hi Morten ,


thanks very much for ur help it worked on ... keep
assisting me in future also .


--- bye
nannu
 

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