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"