Thursday, 15 August 2013

c# - Invalid text, ntext, or image pointer value -



c# - Invalid text, ntext, or image pointer value -

i trying upload file database (by reading binary file contents stored procedure). passing input stream method so:

loadfile(gattachmentcontentid, file.inputstream, trn); public static void loadfile2(guid gattachmentcontentid, stream stm, idbtransaction trn) { stm.position = 0; byte[] binfile_pointer = new byte[32]; // read s byte buffer. byte[] bytes = new byte[stm.length]; int numbytestoread = (int)stm.length; int numbytesread = 0; while (numbytestoread > 0) { // read may homecoming 0 10. int n = stm.read(bytes, numbytesread, 10); // end of file reached. if (n == 0) { break; } numbytesread += n; numbytestoread -= n; } stm.close(); sqlprocs.spattachments_content_writeoffset(gattachmentcontentid, binfile_pointer, 0, bytes, trn); // numbytestoread should 0 now, , numbytesread should // equal 100. console.writeline("number of bytes read: {0:d}", numbytesread); }

with procedure:

public static void spattachments_content_writeoffset(guid gid, byte[] binfile_pointer, int32 nfile_offset, byte[] bybytes, idbtransaction trn) { idbconnection con = trn.connection; using ( idbcommand cmd = con.createcommand() ) { cmd.transaction = trn; cmd.commandtype = commandtype.storedprocedure; if ( sql.isoracle(cmd) ) cmd.commandtext = "spattachments_content_writeoff"; else cmd.commandtext = "spattachments_content_writeoffset"; idbdataparameter parid = sql.addparameter(cmd, "@id" , gid ); idbdataparameter parfile_pointer = sql.addparameter(cmd, "@file_pointer" , binfile_pointer ); idbdataparameter parmodified_user_id = sql.addparameter(cmd, "@modified_user_id", security.user_id ); idbdataparameter parfile_offset = sql.addparameter(cmd, "@file_offset" , nfile_offset ); idbdataparameter parbytes = sql.addparameter(cmd, "@bytes" , bybytes ); cmd.executenonquery(); } }

but next error:

invalid text, ntext, or image pointer value 0x00000000000000000000000000000000.

the error occurs on line cmd.executenonquery(); of stored procedure method.

stored procedure:

create procedure dbo.spattachments_content_writeoffset ( @id uniqueidentifier , @file_pointer binary(16) , @modified_user_id uniqueidentifier , @file_offset int , @bytes image ) encryption begin set nocount on -- 10/22/2005 paul. @id used in oracle , mysql. -- #if sql_server /* updatetext attachments_content.attachment @file_pointer @file_offset null -- 0 deletes no data, null deletes info insertion point. @bytes;

thank you.

since uploading single file per row much easier utilize normal update instead of fiddling around pointers , offsets unnecessarily. command can simple this:

update attachments_content set attachment = @bytes id=@id

i wasn't sure id field was, wrote id i'm sure can substitute right one.

c# sql-server-2008 binary webforms

No comments:

Post a Comment