+ -
当前位置:首页 → 问答吧 → VB获取recordset记录集的时候,出现怪现象。请高手看看

VB获取recordset记录集的时候,出现怪现象。请高手看看

时间:2011-11-27

来源:互联网

VB code
With conn
            .CursorLocation = adUseClient
            .CommandTimeout = 5
            .ConnectionString = " Provider=SQLOLEDB.1;Persist Security Info=True;Data Source=" & dbserver & ";Initial Catalog=" & dbName & ";User ID=" & userName & ";Password=" & psw
'            Debug.Print .ConnectionString
            
            .Open

dim rs As ADODB.Recordset
set rs = nothing
Set rs = conn.Execute(strSQL)
if rs is nothing then
   msgbox "没有获取到数据"
end if
    End With


当执行完 Set rs = conn.Execute(strSQL)这句时候,有时候会出现 rs 是 nothing这种情况。
局域网络不好的时候,就经常出现。
请问应该怎么避免此类情况啊。?

作者: zhoujiyong001   发布时间: 2011-11-27

看来你的局域网速度慢,
.CommandTimeout = 30或者更大些,试试

作者: worldy   发布时间: 2011-11-27

strSQL没有赋值啊?

作者: wangmu7206   发布时间: 2011-11-27

试试Rs.RecordCount=0作为没有数据的判断依据

作者: greatbody   发布时间: 2011-11-27

热门下载

更多