补充:
在得到连接字符串后
直接发送一个命令测试以下即可判断是不是连接到SQL SERVER
dim cn as adodb.connection
dim sCNN as string
on error goto HError
scnn=GetCNNString()
if len(trim(scnn)>0 then
    set cn=new adodb.connection
    cn.open scnn
    cn.excute "select @@SERVERNAME"
    'it is ok
endifexit sub
HError:
'it is bad

解决方案 »

  1.   

    补充:
    在得到连接字符串后
    直接发送一个命令测试以下即可判断是不是连接到SQL SERVER
    dim cn as adodb.connection
    dim sCNN as string
    dim rs  as adodb.recordset
    on error goto HError
    scnn=GetCNNString()
    if len(trim(scnn)>0 then
        set cn=new adodb.connection
        cn.open scnn
    set rs=cn.excute( "select @@VERSION")
    if instr(ucase$(cstr(rs.Fields(0))),"MICROSOFT SQL SERVER")>0 then
        'it is ok
    end if
    endifexit sub
    HError:
    'it is bad