QTP连接DB2数据库的问题
QTP连接DB2数据库时我是这样写的:dim con
con=createobject("ADODB.connection")
con.connectionstring="DRIVER={IBM DB2 ODBC DRIVER};UID=user; PWD=password;MODE=SHARE;DBALILS=mydb"
con.open
if con.state=0 then
msgbox "faile"
else
msgbox "pass"
endif
con.close
set con=nothing
运行到第四行时老是提示:指定的初始化字符串不符合OLE DB规定
请教高手们,这是怎么回事儿啊?
而且我是想连接服务器的数据库,可是我看网上那种连接方式格式没有让写服务器IP的地方啊
[ 本帖最后由 moguiku 于 2010-4-26 14:33 编辑 ] 参考:
各种DB2连接类型
OLE DB, OleDbConnection (.NET) from ms
TCP/IP:
"Provider=DB2OLEDB;Network Transport Library=TCPIP;Network Address=XXX.XXX.XXX.XXX;Initial Catalog=MyCtlg;Package Collection=MyPkgCol;Default Schema=Schema;User ID=MyUser;Password=MyPW"
APPC:
"Provider=DB2OLEDB;APPC Local LU Alias=MyAlias;APPC Remote LU Alias=MyRemote;Initial Catalog=MyCtlg;Package Collection=MyPkgCol;Default Schema=Schema;User ID=MyUser;Password=MyPW"
IBM's OLE DB Provider (shipped with IBM DB2 UDB v7 or above)
TCP/IP:
Provider=IBMDADB2;Database=sample;HOSTNAME=db2host;PROTOCOL=TCPIP;PORT=50000;uid=myUserName;pwd=myPwd;
ODBC
Standard:
"driver={IBM DB2 ODBC DRIVER};Database=myDbName;hostname=myServerName;port=myPortNum;protocol=TCPIP; uid=myUserName; pwd=myPwd" con.connectionstring = "Driver={IBM DB2 ODBC DRIVER};Database=myDataBase;Hostname=myServerAddress;Port=1234; Protocol=TCPIP;Uid=myUsername;Pwd=myPassword;“
回复 3# 的帖子
谢谢啊,我回去试一下回复 2# 的帖子
感谢啊,我回去试一下啊回复 5# 的帖子
不行啊,提示错误:SQL1042C发生意外的系统错误。SQLSTATE=58004
回复 2# 的帖子
不行啊,提示错误:SQL1042C发生意外的系统错误。SQLSTATE=58004 网上有说是版本的问题,我目前的QTP版本是9.2,是不是我把QTP升级到10.0就可以连接DB2的数据库了?? 顶一下,知道的人赶紧来回答一下啊
我也想知道答案。 原帖由 moguiku 于 2010-4-27 11:22 发表 http://bbs.51testing.com/images/common/back.gif
网上有说是版本的问题,我目前的QTP版本是9.2,是不是我把QTP升级到10.0就可以连接DB2的数据库了??
跟QTP的版本应该没有关系,因为都是通过ADO这个COM接口去连接的,检查一下你的ODBC驱动中有没有DB2的驱动
回复 10# 的帖子
这个查过了,有DB2的驱动,可就是不行,也在网上查了不少的资料,试了不少的方法,就是不行,我看网上了有不少人反应这个问题回复 11# 的帖子
什么名字的驱动?试试按这种写法行不行:
Cnn.ConnectionString="Provider=IBMDADB2.1;Password="+db2Pwd+"Persist Security Info=True;User ID="+db2Uid+";DBALIAS="+db2Sid+";Location="";Extended Properties="";" 在国外一个论坛搜到的关于QTP连接DB2出现58004错误的解决办法:
--------------------------------------------------------------------------------
Problem Description: Error: " SQL 1042C An unexpected system error occured. SQLSTATE=58004"
The user receives a " SQL 1042C An unexpected system error occured. SQLSTATE=58004" error message when trying to connect to an IBM DB2 client using a Database Checkpoint or ADODB statements within the script.
Diagnosis: The existence of the <Quicktest Professional>/bin/QTPro.exe.Local file conflicts with the ability of ADODB to open the DB2 client.
--------------------------------------------------------------------------------
Solution: Rename the QTPro.exe.Local file in the bin directory
The QTPro.exe.Local file is used for redirection of DLLs that QuickTest Professional loads. In the case of coexistence problems with other Mercury products, the file instructs Windows API to load DLLs from the <QuickTest Professional>\bin directory instead of other directories. This is important for the coexistence between QuickTest Professional, LoadRunner, and old versions of Astra LoadTest.
Renaming this file should solve the problem. QuickTest Professional will work fine without QTPro.exe.Local, unless LoadRunner or Astra LoadTest are installed on the machine.
1. Close QuickTest Professional.
2. Open Windows Explorer, and navigate to the QuickTest Professional installation directory.
3. In the bin directory, locate the QTPro.exe.Local file, and rename it (for example, QTPro.exe.Local.old).
4. Restart QuickTest Professional.
After renaming the file, QuickTest Professional should be able to connect to the database and work with it as expected. If the error continues, try removing unneeded parameters in the connection string.
回复 13# 的帖子
真的是可以啊!太感谢了!
把那个文件一重命名,一切OK了!
只是这知道这个文件是干什么用的啊?改了以后会不会对以后的测试啥的有影响啊 原帖由 moguiku 于 2010-4-29 15:16 发表 http://bbs.51testing.com/images/common/back.gif
真的是可以啊!
太感谢了!
把那个文件一重命名,一切OK了!
只是这知道这个文件是干什么用的啊?改了以后会不会对以后的测试啥的有影响啊
The QTPro.exe.Local file is used for redirection of DLLs that QuickTest Professional loads. In the case of coexistence problems with other Mercury products, the file instructs Windows API to load DLLs from the <QuickTest Professional>\bin directory instead of other directories. This is important for the coexistence between QuickTest Professional, LoadRunner, and old versions of Astra LoadTest.
不跟LR装在一个机器的话应该没有什么问题的
回复 15# 的帖子
按照上述方法,在我的机子上是跑通了,可是到同事的机子上就跑不通,同事的机子上没有装LR等,不管改不改那个文件名,都是跑不通,还有没有什么解决办法啊?一直这个错误:
SQL1042C发生意外的系统错误。SQLSTATE=58004
[ 本帖最后由 moguiku 于 2010-4-30 17:31 编辑 ]
页:
[1]