We have legacy data which is stored in MSSQL database as varchar, even though the data is really binary. In new application we're using OleDbCommand (because we are trying to use common code to access MSSQL+Oracle+Sybase) databases.
I am able to retrieve data from database by performing:
DA.SelectCommand.CommandText = "select
sequence_num, summary_num, line_num, CONVERT(varbinary, other_information) other_information
from alex_test_bin";
However the insert command:
DA.InsertCommand.CommandText = "insert into alex2_test_bin
(sequence_num, summary_num, line_num, other_information)
values(?, ?, ?, CONVERT(varchar, ?))";
throws this error (it happens during 'DA.Update(DT);'):
No value given for one or more required parameters.
Currently I'm just trying to read data from alex_test_bin and insert the data into alex2_test_bin. In between reading and writing, I'm using method 'SetAdded()' on each row from DT, so that all of those rows get inserted.
Is my insert statement wrong? Is there a way to correct it, and be able to use functions inside insert statement? I successfully ran the insert statement manually from sql manager.