Casting/DB Insertion problem

  • Thread starter Thread starter Jeremy
  • Start date Start date
J

Jeremy

I have a problem inserting/extracting a byte array to/from an Sql DB. The
byte array has a length of 1040. The field in the DB is of type binary (I
have also unsuccessfully tried varbinary). The following example will
explain my problem:

before inserting:
byteArray[0]=144
byteArray[1]=102
....
byteArray[1039]=54

when retrieving from Sql DB and copying back into a byteArray:
byteArray[0]=144
byteArray[1]=0
....
byteArray[1039]=0 (all values starting from position 1 are 0)

So I figure, either I'm not inserting the array correctly in the DB, or I'm
not extracting it correctly.

This is what I'm using right now:

cmd.Parameters.Add("@BiometricData", OleDbType.VarBinary);
cmd.Parameters[8].Value = (byte[])(BiometricData);//casting from Object to
Byte Array

Any help would be greatly appreciated. Been trying to figure this out for a
while a now.. thanks so much!
 
I've tried to use the "image" type but I can't seem to change the size in
Sql Server from 16 to 1040.. I assume that binary should work in the same
way. Am I doing something else wrong perhaps ?
 
it does work! thanks! Do you have any explanation as to why it works? I'm
curious.. I mean a size of 16, isn't that 16 bytes?
 
Back
Top