'Using VBA running MySQL select query returns NULL for BLOB field that is not NULL
My code used to work I'm not sure what happened. I tried restarting the MySQL service.
Image2 is a blob field in a MySQL database. It has data in it, but shows up as NULL when I try and pull that data out. I can retrieve the data from all other non-blob fields. Anyone know what might be going on?
Set rs = CreateObject("ADODB.Recordset")
Server_Name = "xxxx"
Database_Name = "acs"
User_ID = "xxxx"
Password = "xxxx"
table_name = "setcrewreport"
Set cn = CreateObject("ADODB.Connection")
cn.Open "Driver={MySQL ODBC 8.0 Unicode Driver};Server=" & Server_Name & ";Database=" & Database_Name & ";Uid=" & User_ID & ";Pwd=" & Password & ";"
SQry = "SELECT * FROM setcrewreport where Serial = '" & Sheets("Contract").Range("B10").Value & "' AND VisitNumber = '1'"
rs.Open SQry, cn
Serial = rs!Serial <-- has data
Image1 = rs!Image2 <-- NULL
Solution 1:[1]
I found an answer / workaround for this here: https://bugs.mysql.com/bug.php?id=70765
I tried setting the cursorLocation when setting the ADODB Connection as mentioned there. The Error is now history.
Example:
Set conn = New ADODB.Connection
conn.ConnectionString = connectionString
conn.CursorLocation = adUseClient
conn.Open
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharman |
