[Pb] [SQL Server] Pb Accessing BLOB data in the database

Source: Internet
Author: User

I. First, write two functions, namely reading and writing files:
Reference to the function of reading and writing files in Pb: http://blog.csdn.net/xys_777/archive/2010/08/04/5787833.aspx

Ii. Saving files

 

Li_value = getfileopenname ("select file", ls_docname, ls_named) <br/> If li_value = 1 then <br/> If f_readfile (lb_fj, ls_docname) = 1 then <br/> ll_picid = gf_getid ('t_picture ') // This is a function for getting the new ID <br/> // you need to insert other information for this data first <br/> insert into t_svt_picture (pictureid, picname, detaillogid) <br/> values (: ll_picid,: ls_named,: ld_detaillogid); <br/> If sqlca. sqlcode <0 then <br/> rollback; <br/> MessageBox ('System prompt ', 'Data saving failed ') <br/> return <br/> end if <br/> // update the Blob field with updateblob <br/> updateblob t_picture set picblob =: lb_fj where pictureid =: ll_picid; <br/> If sqlca. sqlcode <0 then <br/> rollback; <br/> MessageBox ('System prompt ', 'Save failed ') <br/> return <br/> else <br/> commit; <br/> end if </P> <p>

3. Open a file

// Use selectblob to assign BLOB data to blob variable lb_fj <br/> selectblob picblob into: lb_fj from t_picture where pictureid =: ll_picid; <br/> If sqlca. sqlcode <> 0 then <br/> MessageBox ('System prompt ', 'Data reading failed ') <br/> return <br/> end if <br/> // save the file in the disk again, before saving the database, you need to record the file name dw_1.object.picname <br/> ls_docname = 'C:/worktemp '<br/> if not directoryexists (ls_docname) Then createdirectory (ls_docname) <br/> ls_docname = ls_docname + dw_1.object.picname [row] <br/> If f_writefile (lb_fj, ls_docname) = 1 then <br/> // call the API to open the file <br/> If shellexecutea (handle (parent), ls_null, ls_docname, ls_null, ls_null, 1)> 32 then <br/> return <br/> else <br/> MessageBox ('System prompt ', 'file opening error ') <br/> return <br/> end if </P> <p> // API definition <br/> function long shellexecutea (ulong hwnd, string lpoperation, string lpfile, string lpparameters, string lpdirectory, long nshowcmd) Library "shell32.dll"

Related Article

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.