热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

MySQLODBC5.1驱动程序向ADODB返回错误的数据类型-MySQLODBC5.1driverreturnswrongdatatypetoADODB

Situation:workingwithlegacyclassicASPcode,attemptingtomovethecodebasefromanoldserver

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

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

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.

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

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

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

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

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

Microsoft Vbscript运行时错误“800a01ca”变量使用Vbscript中不支持的自动化类型

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.

如果我使用cLng()手动转换字段,则会消除错误并返回正确的值。但是,有太多代码可以手动查找每个对整数的引用并手动转换它。

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)

VarType()为这些值返回19,这似乎是VB无法理解的某种类型的Long数据类型。 (请参阅此处)ODBC驱动程序是否应该为长整数返回VarType 3? (看这里)

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

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

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.

知道怎么纠正这个吗?似乎应该有一个选项传递给MySQL ODBC驱动程序返回long作为Long Integer数据类型,但我找不到它。

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.

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

1 个解决方案

#1


1  

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.

通过消除过程确定我终于发现了问题。不知道为什么会发生这种情况,但它必须是MySQL ODBC驱动程序中的错误。

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.

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

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.

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

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 Driver论坛中发布了此问题,但没有人愿意回应。


推荐阅读
author-avatar
wugege
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有