ADO打开指针类型研究(一)CursorType Property (ADO)

这是一个很实际的问题,先说一下我的测试代码,VB环境

    DBstr = "select * from UserInfo where UserID='" & UsrID & "'"

    check.Open DBstr, DBCnn, adOpenStatic, adLockReadOnly
    re(0) = check.RecordCount
    check.Close
    check.Open DBstr, DBCnn, adOpenDynamic, adLockReadOnly
    re(1) = check.RecordCount
    check.Close
    check.Open DBstr, DBCnn, adOpenForwardOnly, adLockReadOnly
    re(2) = check.RecordCount
    check.Close
    check.Open DBstr, DBCnn, adOpenKeyset, adLockReadOnly
    re(3) = check.RecordCount
    check.Close

    MsgBox re(0) & "*" & re(1) & "*" & re(2) & "*" & re(3)
   

结果:    1 * -1 * -1 * 1

这个返回结果对于需要使用如下语句进行判断很关键:

    If check.RecordCount <= 0 Then
        MsgBox "Error 1"
        check.Close
        Exit Sub
    Else

分析:首先肯定上述SQL肯定的一致性,并且获得了一条结果,但是返回值却是不同。之所以这样,还是看看专业的文章,我也消化一下,下次再进一步分析。

http://msdn2.microsoft.com/en-us/ms677593.aspx

原文地址:https://www.cnblogs.com/ainima/p/6331532.html