0

我正在尝试获取 db 中表的行数并使用 VBScript 将其输出到控制台,但是当我执行以下代码时出现类型不匹配错误,我应该在我的代码中更改什么以强制它无错误地执行

Dim loop_lim
Const DB_CONNECT_STRING = "Provider=SQLOLEDB.1;Data Source=BUG\SQLSERVER2005;Initial Catalog=test;user id ='sa';password='111111'"
Set myConn = CreateObject("ADODB.Connection")
Set myCommand = CreateObject("ADODB.Command" )
myConn.Open DB_CONNECT_STRING
Set myCommand.ActiveConnection = myConn
myCommand.CommandText = "select count(*) from oferty o inner join rep_oferta ro on o.indeks = ro.srcdoc inner join rep_pozycje rp on o.indeks = rp.srcdoc"
loop_lim = myCommand.Execute
WScript.Echo loop_lim
4

1 回答 1

1

改变

loop_lim = myCommand.Execute

Set loop_lim = myCommand.Execute

因为 .Execute 返回一个记录集对象。然后考虑如何从记录集 rsp 中获取值。它的领域。

于 2013-04-22T12:51:34.170 回答