error in update command using dataadapter

  • Thread starter Thread starter nannu
  • Start date Start date
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
 
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.
 
Hi Morten ,


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


--- bye
nannu
 
Back
Top