0

I have in mysql table - products (product_id int, name varchar, description text).
I use latest ODBC driver to connect to mysql from excel (VBA) with parametrized query:

dim DCONT as ADODB.Connection
set DCONT = new ADODB.Connection
DCONT.open "DSN=myDSN"

set cmd = new ADODB.command
cmd.commandtext = "SELECT product_id, name FROM products WHERE name LIKE ?" 
set param1=cmd.createparameter("@strName", advarchar, adparaminput, 30, "%testvalue%"
cmd.parameters.append param1
cmd.activeconnection = DCONT
dim rsRecords = new ADODB.recordset
rsRecords.open cmd

This code return requested records correctly. When I change commandtext to (query included the field description from table (field type text))

cmd.commandtext = "SELECT product_id, name, description FROM products WHERE name LIKE ?" 

it returns No record. In the same way when I use this query

cmd.commandtext = "SELECT * FROM products WHERE name LIKE ?" 

it returns No record.

Next code without parametrized query returns requested record. It means there is a problem with returning records only by use parametrized query.

dim DCONT as ADODB.Connection
set DCONT = new ADODB.Connection
DCONT.open "DSN=myDSN"

set cmd = new ADODB.command
cmd.commandtext = "SELECT product_id, name, description FROM products WHERE name LIKE '%testvalue%'"
cmd.activeconnection = DCONT
dim rsRecords = new ADODB.recordset
rsRecords.open cmd

Any advice please?

4

1 回答 1

0

解决方案 -> 需要升级到最新的 MySQL ODBC 8.0 ANSI Driver,版本 8.00.13.00,然后一切正常。

于 2018-11-02T12:01:57.913 回答