ocmd.Connection = ocon; I think this line is wrong. Itmust be ; ocmd.Connection = conn;
2009/4/11 AstroDrabb <[email protected]> > > On Wed, Apr 8, 2009 at 10:07 PM, JeffNielson <[email protected]> > wrote: > > > > My code below gives no errors, but it doesn't actually update the > > database (Access 2000, I believe). If I copy the query from the > > console (see that I writeline it), it will run in Access with no > > problems. I use VS2005. Yes, I am checking the database in the bin > > directory. > > > > Thanks. > > > > > <snip> > > Use a OleDbCommand object and the ExecuteNonQuery() method. I.E. > > using System.Data.OleDb; > > ... > > OleDbConnection conn = new OleDbConnection(connString); > OleDbCommand ocmd = new OleDbCommand(); > ocmd.Connection = ocon; > ocmd.CommandType = CommandType.Text; > ocmd.CommandText = qry; > int rowsAffected = ocmd.ExecuteNonQuery(); > if (rowsAffected > 0) > System.Diagnostics.Debug.WriteLine("Hey, I updated some rows!"); >
