|
I try to find a solution from many places, but not yet solved...and hence I have a
different issue for update dbf file [free table -vfp] from C# OleDbDataAdapter.
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();
Thanks For The Helps
|
|
|
|
|
Your update-command has three question marks (parameters), yet you assign only two. s1_no isn't added, and will be required.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy.
While posting time unchecked, but my original code is
VFPDAp.InsertCommand.CommandText = "insert into my_table1 (my_time,reminder) values(?, ?)";
VFPDAp.UpdateCommand.CommandText = "update my_table1 set my_time=?, reminder=? where reminder=? ";
But showing the same error,
SQL: Column 'Q0P2' is not found
Thanks Again
|
|
|
|
|
Paramu1973 wrote: "update my_table1 set my_time=?, reminder=? where reminder=? ";
Same answer still; you have 3 question-marks in there. That means that a IDbCommand will expect three parameters. It will fail if you only supply 2. From the previous code, it looks as if the primary key is missing.
"Which" record would the statement update? You'll either have to remove the condition (in which case "ALL" records will be updated, which is prolly false) or supply the third parameter.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hi Eddy,
Thanks.......you cleared my 1 1/2 days headache...
Thousands of thanks to you....
Really, I become very upset because of that crazy error...
Thanks Again
|
|
|
|