怎样从SQL数据库中读取图片,将他存为文件
1个回答
展开全部
Public Function ReadFromDb(ByRef conn As ADODB.Connection, ByVal strTbl As String, ByVal strFl As String, ByVal strCondi As String) As Boolean
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "select top 1 * from " & strTbl & " where " & strCondi, conn, 3, 2
If rs.EOF Or IsNull(rs(strFl)) Then
ReadFromDb = False
Exit Function
End If
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.Write rs.Fields(strFl).Value
mstream.SaveToFile "c:\carrot.gif", adSaveCreateOverWrite
rs.Close
ReadFromDb = True
End Function
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "select top 1 * from " & strTbl & " where " & strCondi, conn, 3, 2
If rs.EOF Or IsNull(rs(strFl)) Then
ReadFromDb = False
Exit Function
End If
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.Write rs.Fields(strFl).Value
mstream.SaveToFile "c:\carrot.gif", adSaveCreateOverWrite
rs.Close
ReadFromDb = True
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询