VBScript:连接到ODBC失败,并显示错误消息“对象关闭时不允许操作”

时间:2013-04-18 17:51:18

标签: database vbscript odbc database-connection

我有下面的代码,它给我一个错误“当对象关闭时不允许操作”。我在这里缺少什么?

 Dim dbconnect, dbresults

 Set dbconnect = CreateObject("ADODB.Connection")
 Set dbresult = CreateObject("ADODB.Recordset")

dbconnectString =  "driver=iSeries Access ODBC Driver;System=***;UID=***;PWD=***;Naming=1"
dbconnect.Open (dbconnectString)        
mySQLQuerry ="Select XOORIG  from FIQDLIB.FSFPXO as400xo WHERE as400xo.xoefdt = 1130418 and as400xo.xotrsq in (75440)"
dbresult.Open mySQLQuerry, dbconnect

1 个答案:

答案 0 :(得分:0)

打开连接后,使用WScript.Echo dbconnect.State检查connection state。您的连接字符串也会关闭。根据{{​​3}},驱动程序名称应该用大括号括起来。