>row["title"]="Manager"; >ds.AcceptChanges(); >>
using System; using System.Data; using System.Data.OleDb; class test { static void Main() { string strConn = @"Provider=VFPOLEDB;Data source= C:\Program Files\Microsoft Visual FoxPro 9\Samples\Data\testdata.dbc;"; OleDbConnection cn = new OleDbConnection(strConn); // Prepare command and parameters string strQuery = "select * from orders where cust_id = ? and order_date between ? and ?"; string strUpdate = "update orders set to_region = ? where order_id = ?"; OleDbCommand cmd = new OleDbCommand(strQuery,cn); OleDbParameter customerID = cmd.Parameters.Add("customerID",OleDbType.Char); OleDbParameter startDate = cmd.Parameters.Add("startDate",OleDbType.Date); OleDbParameter endDate = cmd.Parameters.Add("endDate",OleDbType.Date); customerID.Value = "BONAP"; startDate.Value = new DateTime(1995,1,1); endDate.Value = new DateTime(1995,5,30); OleDbCommand cmdUpdate = new OleDbCommand(strUpdate,cn); OleDbParameter region = cmdUpdate.Parameters.Add("region",OleDbType.Char); OleDbParameter orderID = cmdUpdate.Parameters.Add("orderID",OleDbType.Char); region.SourceColumn = "to_region"; orderID.SourceColumn = "order_id"; orderID.SourceVersion = DataRowVersion.Original; OleDbDataAdapter da = new OleDbDataAdapter(); da.SelectCommand = cmd; da.UpdateCommand = cmdUpdate; DataSet ds = new DataSet(); da.Fill(ds); // now, if you want to see your data, as Cetin showed in his example: foreach (DataRow row in ds.Tables[0].Rows) { Console.WriteLine("Customer ID: {0}, Order ID: {1}, Ordered on: {2}", (string)row["cust_id"], (string)row["order_id"], (DateTime)row["order_date"]); } DataRow row0 = ds.Tables[0].Rows[0]; DataRow row1 = ds.Tables[0].Rows[1]; row0["to_region"] = "HelloVFP"; row1["to_region"] = "FromC#"; da.Update(ds); } }Note that when using with VFP parameters are mapped to source by their ordinal positions and not names as in SQL server. IOW the first parameter added points to first ?, second to 2nd ? and so on whatever their parameter name is in your code (I might well say "myRegion" instead of "region" or "blahblah". It knows it's ? parameter in "...to_region = ? ..." just because in update command it's the first parameter and I add 'region' first to parameters collection. Hope clear).