patrick

patrick

  • NA
  • 397
  • 0

Insert Binary Array into a row.

Jun 22 2009 10:58 AM
I deleted my other post because I've narrowed down the problem. The data type of the "Data" field is image.

public static void serializeAndStoreData(Data D){
ADODB.Connection conData = new ADODB.Connection();
string strSQL;
object obj = new object();
Guid g = Guid.NewGuid();
Byte[] B = new byte[10];
B=ObjectByteArrayConverter.ObjectToByteArray(D);
conData.Open("Provider=Microsoft.Jet.OLEDB.4.0;"+ "Data Source=" +Properties.Settings.Default.networkedConString, "", "", 0);
strSQL = "INSERT INTO Test (ID, Data) VALUES('" + g + "', '" + B + "' );";
conData.Execute(strSQL, out obj, 0);
conData.Close();
}
I know the serialize works. for some reason, when i pull out data and cast it to byte[], it isnt right. For example, a byte[2000] goes into the database and comes out as byte[30].