database - C# adding large bytearray(image) as paramter to dbcommand -
i'm in process of creating manual db layer project. i've stumbled on problem when tried store byte arrays (images) larger 8k.
normally use following create commands , fill parameters:
dbcommand cmd = new sqlcommand("insert test1 values (@mail, @picture)"); i=cmd.declareparameter(cmd, "mail", dbtype.string, "mail"); if (i>0) { cmd.parameters[i].value = maildata; } (the above cut multiple methods use). when try add picture (which byte[]) problem need use sqldbtype.varbinary there.
i've seen few solutions use .parameters.add add have takes 1 (and not 2 parameters in examples saw). when try create own parameter cmd.createparameter dbtype takes dbtype , not want sqldbtype.
what have here able add byte[] parameter (for byte arrays larger 8k)?
tnx
when try create own parameter cmd.createparameter dbtype takes dbtype , not want sqldbtype
that's because declared command dbcommand instead of sqlcommand. if declare sqlcommand should work:
|------ v sqlcommand cmd = new sqlcommand("insert test1 values (@mail, @picture)"); cmd.parameters.addwithvalue("@mail", maildata); sqlparameter p = cmd.parameters.add("@picture", sqldbtype.varbinary); p.value = {picture data};
Comments
Post a Comment