dim adoCmd as adodb.commandset adoCmd=new adodb.command
adoCmd.activeconnextion=yourconnection
adoCmd.excute "Sql"

解决方案 »

  1.   

    Dim tstrConn As String
    Set PubConnect = New ADODB.Connection
    tstrConn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=LSWaterData;Data Source=12.56.21.12;Network Library=DBMSSOCN"
    PubConnect.Open tstrConn    
    Dim tobjRecord  As Object
        Set tobjRecord = CreateObject("Adodb.Recordset")
        '------------
    XtstrSql="update cwgl set jsr='llpp'"
        tobjRecord.Open XtstrSql, PubConnect, adOpenKeyset, adLockOptimistic
        Set GetRecord = tobjRecord
        Set tobjRecord = Nothing
      

  2.   

    在模块中:Public dars As New ADODB.Recordset 'ADO结果集
    在过程中:
     
    If dars.State = adStateOpen Then dars.Close
                                        sql = "update da set 大类名称='" & Trim(TxtDa(0).Text) & "',大类目录='" & Trim(TxtDa(1).Text) & "'  where 大类序号=" & CInt(Trim(Mid(TreeView1.SelectedItem.Key, 3, Len(TreeView1.SelectedItem.Key) - 2))) & ""
                                        dars.Open sql, cn, adOpenKeyset, adLockBatchOptimistic