Dim RS as new ADODB. recordset
Dim conn as new ADODB. Connection
Private sub form_load ()
Conn. Open "provider = sqloledb.1; persist Security info = false; user id = sa; Password = 1234; initial catalog = kepu; Data Source = founder"
Rs. Open "news", Conn, 3, adlockoptimistic, adcmdtable
End sub
Private sub commandementclick ()
Dim stmpic as ADODB. Stream
'On error goto err
Set rs = conn. Execute ("select imgsize, newsid, IMG from News ")
Strpath = "D:/image"
Set stmpic = new ADODB. Stream
Dim strfilename as string
Rs. movenext
While not Rs. EOF
If Rs. Fields ("imgsize")> 0 then' has a graph
Strfilename = strpath + "/kepu" + STR (Rs. Fields ("newsid") + ". jpg"
With stmpic
. Type = adtypebinary
. Open
. Write Rs. Fields ("IMG") 'writes data in the database to the stream.
. Savetofile strfilename, adsavecreateoverwrite 'write the data in stream to the temporary file.
. Close
End
Else
End if
Rs. movenext
Wend
Msgbox "image exported"
Rs. Close
'Picture2. Picture = loadpicture (strpictemp) 'use the picture control to display images
Exit sub
Err:
Msgbox err. Description
End sub
Private sub command2_click ()
Dim strcontent as ADODB. Stream
'On error goto err
Set rs = conn. Execute ("select newsid, content from News ")
Strpath = "D:/html"
Set strcontent = new ADODB. Stream
Dim strfilename as string
Rs. movenext
While not Rs. EOF
Strfilename = strpath + "/kepu" + STR (Rs. Fields ("newsid") + ". htm"
With strcontent
. Type = adtypetext
. Open
. Writetext Rs! Content 'write the data in the database to the stream
. Savetofile strfilename, adsavecreateoverwrite 'write the data in stream to the temporary file.
. Close
End
Rs. movenext
Wend
Msgbox "content exported"
Rs. Close
'Picture2. Picture = loadpicture (strpictemp) 'use the picture control to display images
Exit sub
Err:
Msgbox err. Description
End sub