MySQL ODBC 5.1驱动程序向ADODB返回错误的数据类型 [英] MySQL ODBC 5.1 driver returns wrong datatype to ADODB

查看:64
本文介绍了MySQL ODBC 5.1驱动程序向ADODB返回错误的数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况:使用传统的经典ASP代码,尝试将代码库从旧服务器迁移到新服务器.

Situation: working with legacy classic ASP code, attempting to move the codebase from an old server to a new one.

代码尝试使用MySQL ODBC 5.1驱动程序和ADODB.Connection对象连接到Windows服务器上的MySQL数据库.

The code attempts to connect to a MySQL database on a Windows server using the MySQL ODBC 5.1 driver and the ADODB.Connection object.

Connection String = "Driver={MySQL ODBC 5.1 Driver};Server=dbserver;Database=dbname;Uid=username;Password=password;Option=3"

查询结果在ADODB.RecordSet对象中返回.当我尝试访问包含标准MySQL整数的字段时,出现此错误:

Query results are returned in ADODB.RecordSet objects. When I try to access a field containing a standard MySQL Integer, I get this error:

Microsoft VBScript运行时错误'800a01ca'
变量使用VBScript不支持的自动化类型

Microsoft VBScript runtime error '800a01ca'
Variable uses an Automation type not supported in VBScript

如果我使用cLng()手动转换字段,则错误将消除,并返回正确的值.但是,有太多代码无法手动查找每个对整数的引用并进行手动转换.

If I manually convert the field using cLng() then the error is eliminated and the correct value is returned. However, there is too much code to manually look for each reference to an integer and manually convert it.

VarType()对于这些值返回19,这似乎是VB无法识别的某种Long数据类型.(请参阅此处)ODBC驱动程序不是应该为长整数返回VarType 3吗?(请参见此处)

VarType() returns 19 for these values, which appears to be some type of Long datatype that VB doesn't understand. (See here) Isn't the ODBC driver supposed to return VarType 3 for long integers? (see here)

我尝试在连接字符串的"option ="参数中传递选项16384(NO_BIGINT),但没有任何区别.

I tried passing the option 16384 (NO_BIGINT) in the "option=" parameter of the connection string but it didn't make any difference.

有什么主意要纠正吗?似乎应该有一个传递给MySQL ODBC驱动程序的选项,以将long作为Long Integer数据类型返回,但我找不到它.

Any idea how to correct this? It seems there should be an option to pass to the MySQL ODBC driver to return longs as Long Integer datatype, but I can't find it.

在任何人提到它之前:是的,我们知道经典ASP是不好的.不,我们现在没有资源将此代码移植到其他东西.我们只需要它就可以在当前时间继续使用经典ASP.

Before anyone mentions it: yes we know classic ASP is bad. No we don't have the resources to port this code to something else right now. We just need it to continue working on classic ASP for the current time.

推荐答案

确定,我终于发现了问题所在.不知道为什么为什么发生这种情况,但这一定是MySQL ODBC驱动程序中的错误.

OK by the process of elimination I finally discovered the problem. Not sure why this occurs but it must be a bug in the MySQL ODBC driver.

具有UNSIGNED属性的整数字段会导致错误.删除此属性会使字段值作为标准的Integer类型返回.显然,ODBC驱动程序不能正确处理从unsigned int到vbscript Integer类型的转换,而是返回一个指向Long的指针.

Integer fields having the UNSIGNED attribute cause the error. Removing this attribute causes the field value to be returned as a standard Integer type. Apparently the ODBC driver is not handling the conversion from unsigned int to vbscript Integer type properly, and is instead returning a pointer to a Long.

我还在我用作布尔值的tinyint(1)字段上注意到了这个问题.将数据类型从tinyint(1)更改为int(11)(默认设置)也消除了此错误.

I also noticed this problem on tinyint(1) fields which I was using as boolean values. Changing the datatype from tinyint(1) to int(11) [the default] eliminated this error also.

希望这会对其他人有所帮助.仅供参考,我还在MySQL ODBC驱动程序论坛上发布了此问题,但没有人愿意回答.

Hopefully this will help someone else. FYI I also posted this issue in the MySQL ODBC Driver forum but nobody bothered to respond.

这篇关于MySQL ODBC 5.1驱动程序向ADODB返回错误的数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆