51Testing软件测试论坛

标题: QTP连接DB2数据库的问题 [打印本页]

作者: moguiku    时间: 2010-4-26 14:15
标题: 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 编辑 ]
作者: TIB    时间: 2010-4-26 17:07
参考:
各种DB2连接类型   
   
OLE   DB,   OleDbConnection   (.NET)   from   ms     
  
TCP/IP:   
  "rovider=DB2OLEDB;Network   Transport   Library=TCPIP;Network   Address=XXX.XXX.XXX.XXX;Initial   Catalog=MyCtlgackage   Collection=MyPkgCol;Default   Schema=Schema;User   ID=MyUserassword=MyPW"     
  
APPC:   
  "rovider=DB2OLEDB;APPC   Local   LU   Alias=MyAlias;APPC   Remote   LU   Alias=MyRemote;Initial   Catalog=MyCtlgackage   Collection=MyPkgCol;Default   Schema=Schema;User   ID=MyUserassword=MyPW"     
   

  IBM's   OLE   DB   Provider   (shipped   with   IBM   DB2   UDB   v7   or   above)     
  TCP/IP:   
  Provider=IBMDADB2;Database=sample;HOSTNAME=db2hostROTOCOL=TCPIPORT=50000;uid=myUserName;pwd=myPwd;     
   

  ODBC     
  Standard:   
  "driver={IBM   DB2   ODBC   DRIVER};Database=myDbName;hostname=myServerName;port=myPortNum;protocol=TCPIP;   uid=myUserName;   pwd=myPwd"
作者: Haereticus    时间: 2010-4-26 17:14
con.connectionstring = "Driver={IBM DB2 ODBC DRIVER};Database=myDataBase;Hostname=myServerAddressort=1234; Protocol=TCPIP;Uid=myUsernamewd=myPassword;“
作者: moguiku    时间: 2010-4-27 08:27
标题: 回复 3# 的帖子
谢谢啊,我回去试一下
作者: moguiku    时间: 2010-4-27 08:28
标题: 回复 2# 的帖子
感谢啊,我回去试一下啊
作者: moguiku    时间: 2010-4-27 10:06
标题: 回复 5# 的帖子
不行啊,提示错误:
[IBM][CLI Driver] SQL1042C  发生意外的系统错误。  SQLSTATE=58004
作者: moguiku    时间: 2010-4-27 10:06
标题: 回复 2# 的帖子
不行啊,提示错误:
[IBM][CLI Driver] SQL1042C  发生意外的系统错误。  SQLSTATE=58004
作者: moguiku    时间: 2010-4-27 11:22
网上有说是版本的问题,我目前的QTP版本是9.2,是不是我把QTP升级到10.0就可以连接DB2的数据库了??
作者: 小米tone    时间: 2010-4-27 16:44
顶一下,知道的人赶紧来回答一下啊
我也想知道答案。
作者: TIB    时间: 2010-4-28 10:37
原帖由 moguiku 于 2010-4-27 11:22 发表
网上有说是版本的问题,我目前的QTP版本是9.2,是不是我把QTP升级到10.0就可以连接DB2的数据库了??

跟QTP的版本应该没有关系,因为都是通过ADO这个COM接口去连接的,检查一下你的ODBC驱动中有没有DB2的驱动
作者: moguiku    时间: 2010-4-28 16:20
标题: 回复 10# 的帖子
这个查过了,有DB2的驱动,可就是不行,也在网上查了不少的资料,试了不少的方法,就是不行,我看网上了有不少人反应这个问题
作者: TIB    时间: 2010-4-28 21:46
标题: 回复 11# 的帖子
什么名字的驱动?

试试按这种写法行不行:
Cnn.ConnectionString="rovider=IBMDADB2.1assword="+db2Pwd+"ersist Security Info=True;User ID="+db2Uid+";DBALIAS="+db2Sid+";Location="";Extended Properties="";"
作者: TIB    时间: 2010-4-28 21:54
在国外一个论坛搜到的关于QTP连接DB2出现58004错误的解决办法:
--------------------------------------------------------------------------------
Problem Description: Error: "[IBM][CLI Driver] SQL 1042C An unexpected system error occured. SQLSTATE=58004"

The user receives a "[IBM][CLI Driver] 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.
作者: moguiku    时间: 2010-4-29 15:16
标题: 回复 13# 的帖子
真的是可以啊!
太感谢了!
把那个文件一重命名,一切OK了!
只是这知道这个文件是干什么用的啊?改了以后会不会对以后的测试啥的有影响啊
作者: TIB    时间: 2010-4-29 15:28
原帖由 moguiku 于 2010-4-29 15:16 发表
真的是可以啊!
太感谢了!
把那个文件一重命名,一切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装在一个机器的话应该没有什么问题的
作者: moguiku    时间: 2010-4-30 17:30
标题: 回复 15# 的帖子
按照上述方法,在我的机子上是跑通了,可是到同事的机子上就跑不通,同事的机子上没有装LR等,不管改不改那个文件名,都是跑不通,还有没有什么解决办法啊?
一直这个错误:
[IBM][CLI Driver] SQL1042C  发生意外的系统错误。  SQLSTATE=58004

[ 本帖最后由 moguiku 于 2010-4-30 17:31 编辑 ]




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2