|
库文件dbManager.qfl代码如下:
Option Explicit
Public function open_cnn()
Dim cnn
Set cnn = createObject("adodb.connection")
Dim connectString
connectString="Provider=SQLOLEDB.1;Password=pass1;Persist Security Info=True;User ID=sa;Initial Catalog=DB;Data Source=10.20.45.56"
cnn.open connectString
Set open_cnn=cnn
end function
Public function open_res(cnn,sql)
Dim res
Set res = createObject("adodb.recordset")
sql = "select DeptName from Depts where DeptID = '123466789'"
res.open sql,cnn
res.movefirst
Set open_res=res
end function
Public function closeCnn(cnn)
cnn.close
Set cnn=nothing
End Function
Public function closeRes(res)
If not (res=null) Then
res.close
End If
Set res=nothing
End Function
test中代码如下:
Dim strConn
strConn =open_cnn()
Dim strRes
strRes = open_res(strConn,sql)
If (strRes.eof) Then
msgbox "a"
End If
if (strRes.count>0) then
msgbox strRes(0)
end if
question:
1,为什么执行到strRes.EOF报错,报错信息见图
2,取消
If (strRes.eof) Then
msgbox "a"
End If
这段代码
当返回的记录集strRes有数据时,count=1;没数据时,count也是=1
为什么?
代码写的很白痴,,,,见笑了 |
|