Hello,
I'm having trouble with the following code, and am wondering if there is a problem with what i'm trying to do. I'm trying to read blob data which contains a bmp file into a local file so I can open it.
This isn't necessarily specific to VBA, but I'm working in VBA so I'm posting it here.
VB Code:
Dim mystream As ADODB.Stream Dim rst As ADODB.Recordset Dim Cnxn As ADODB.Connection ' connection to db Dim strCnxn As String ' connection arguments Dim strSQL As String ' query var Set Cnxn = New ADODB.Connection Set rst = New ADODB.Recordset strCnxn = ThisWorkbook.strCnxn Cnxn.CursorLocation = adUseClient Cnxn.Open strCnxn Set mystream = New ADODB.Stream mystream.Type = adTypeBinary rst.Open "SELECT * FROM bay_pictures limit 1", Cnxn mystream.Open mystream.Write rst.Fields("pic_data").Value mystream.SaveToFile "c:\" & rst!pic_name, adSaveCreateOverWrite mystream.Close
The code generates and E_FAIL -2147467259 (800040005) on the line where I call
VB Code:
mystream.Write rst.Fields("pic_data").Value
Any suggestions?




Reply With Quote