|
- Sub ReadPicture()
- '引用ADODB
- Dim cn As New ADODB.Connection
- Dim rs As New ADODB.Recordset
- Dim trm As New ADODB.Stream
- Dim strcn As String, sql As String
- strcn = "provider=sqloledb;Data source=xxxx;uid=sa;pwd=xx;database=xxx"
- cn.Open strcn
- Dim imgFile As String
- imgFile = "D:\tmp.png"
- sql = "select * from test1"
- rs.Open sql, cn, , , adCmdText
- If Not rs.EOF Then
- With trm
- .Type = adTypeBinary
- .Open
- .Write rs!pvalue
- .SaveToFile imgFile, adSaveCreateOverWrite
- End With
- End If
- rs.Close
- cn.Close
- End Sub
复制代码 |
|