我的问题仍然没有解决,因此我从C#OleDbDataAdapter回来了更新dbf文件[free table -vfp]的不同问题。
string MyConStr = "Provider=VFPOLEDB.1; Data Source='C:\\Temp'; Persist Security Info=False";
VFPDAp = new OleDbDataAdapter();
VFPDAp.InsertCommand = new OleDbCommand();
VFPDAp.UpdateCommand = new OleDbCommand();
VFPDAp.InsertCommand.CommandText = "insert into my_table1 (my_time,reminder) values(?, ?, ?)";
VFPDAp.UpdateCommand.CommandText = "update my_table1 set my_time=?, reminder=? where sl_no=? ";
VFPDAp.InsertCommand.Connection = OleCon1;
VFPDAp.UpdateCommand.Connection = OleCon1;
OleDbParameter Par1 = new OleDbParameter("my_time", -1);
Par1.DbType = DbType.String;
Par1.SourceColumn = "my_time";
Par1.ParameterName = "my_time";
OleDbParameter Par2 = new OleDbParameter("reminder", -1);
Par2.DbType = DbType.String;
Par2.SourceColumn = "reminder";
Par2.ParameterName = "reminder";
OleDbParameter Par3 = new OleDbParameter("my_time", -1);
Par3.DbType = DbType.String;
Par3.SourceColumn = "my_time";
Par3.ParameterName = "my_time";
OleDbParameter Par4 = new OleDbParameter("reminder", -1);
Par4.DbType = DbType.String;
Par4.SourceColumn = "reminder";
Par4.ParameterName = "reminder";
VFPDAp.InsertCommand.Parameters.Add(Par1);
VFPDAp.InsertCommand.Parameters.Add(Par2);
VFPDAp.UpdateCommand.Parameters.Add(Par3);
VFPDAp.UpdateCommand.Parameters.Add(Par4);
OleCon1.ConnectionString = MyConStr;
OleCon1.Open();
VFPDAp.Update(VfpTbl);
OleCon1.Close();
感谢帮助
答案 0 :(得分:2)
您的Insert语句有3个“?”但只有2个parms
insert into my_table1 (my_time,reminder) values(?, ?, ?)
(should it be 3 columns inserted or 2...)
update my_table1 set my_time=?, reminder=? where sl_no=?
每个“?”需要它自己的参数,所以你需要总共5(或6通过插入)