Implementation of step-by-step Writing of binary streams to the database (implemented in SPS)

Source: Internet
Author: User

First, use the WSS interface to add the document DOC

// Sqlconnection Cn = new sqlconnection (configurationsettings. appsettings ["sps_site"]. tostring ());
// CN. open ();
// Sqlcommand cmd = cn. createcommand ();
// Doc = folder. adddocument (filename, new byte [0], false );
// Try
//{
// Doc. ID = convert. toint32 (Doc. spfile. item ["ID"]);
//// Change the size
// Cmd. commandtext = "Update docs set size =" + filesize. tostring () + "where doclibrowid =" + Doc. ID + "and listid = '" + doclibguid + "'";
// Cmd. executenonquery ();
//
// Cmd. commandtext = "declare @ content varbinary (16 )"
// + "Select @ content = textptr (content) from docs where doclibrowid =" + Doc. ID + "and listid = '" + doclibguid + "'"
// + "Updatetext docs. Content @ content @ length 0 @ block ";
// Cmd. Parameters. Add ("@ block", system. Data. sqldbtype. Image );
// Cmd. Parameters. Add ("@ length", system. Data. sqldbtype. INT );
// Int Len = 8040000;
// Byte [] doublebuffer = new byte [Len];
// Int Iread = 0;
// While (Iread <filesize)
//{
// Singlefile. inputstream. Read (doublebuffer, 0, Len );
// Cmd. Parameters ["@ block"]. value = doublebuffer;
// Cmd. Parameters ["@ length"]. value = Iread;
// Cmd. executenonquery ();
// Iread + = Len;
//}
//}
// Catch (exception ex)
//{
// Folder. deletedocument (filename );
// Throw ex;
//}
// Finally
//{
// CN. Close ();
// CN. Dispose ();
//}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.