////Ado
Dim StrCon As String
StrCon = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;" _
     & "Initial Catalog=你的数据库名称;Data Source=" & 你的IP地址 & ";" _
     & "Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;" _
     & "Use Encryption for Data=False;Tag with column collation when possible=False"
            
dim AcSys  as new adodb.connection 
   With AcSys
      If .State = adStateOpen Then .Close
      .ConnectionString = StrCon
      .ConnectionTimeout = 30
      .Open
    End With
///////

解决方案 »

  1.   

    ///////DaoSet  qdserver=dbserver.CreateQueryDef(  "  ")  
    strSQL="EXEC  [SP]  @CODE_IN  =  'BATCHEXCHANGE'  "  
    With  qdserver  
         .Connect="odbc;driver={SQL  Server};database=datqbase;server=servername;pwd=123  "  
         .ReturnsRecords=True  
         .SQL  =  strSQL  
          Set  rsBatch=.OpenRecordset(dbOpenSnapshot,dbSQLPassThrough)  
    End  With
      

  2.   

    dim ac_tmp    as new adodb.connection
    dim ar_tmp    as new adodb.recordset
    with ac_tmp
    ...
    ...
    end withtxtSQL = "select 名称 from 学生表 where 号码='"& combobox.text &"'"
    with ar_tmp
        if .state=adstateopen then .close
        .open txtSQL,ac_tmp,adopenkeyset,adlockreadonly
    end withif ar_tmp.recordcount>0 then
        text.text=ar_tmp!名称 
    else
        text.text=""
    endif