Results 1 to 3 of 3

Thread: HOW TO run sql by adodc1,use adCmdStoredProc?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2020
    Posts
    1,635

    HOW TO run sql by adodc1,use adCmdStoredProc?

    adodc1.commandtype=adCmdStoredProc

    access (test.mdb) have a query name "deleteAll",sql is:
    Code:
    DELETE * FROM table1;
    how to run "deleteAll" by adodc1?

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2020
    Posts
    1,635

    Re: HOW TO run sql by adodc1,use adCmdStoredProc?

    Code:
    Adodc3.CommandType = adCmdStoredProc
    Adodc3.RecordSource = "deleteAll"

    Code:
     
    Adodc1.Recordset.ActiveConnection.Execute Adodc3.RecordSource
    Adodc1.Recordset.Requery
    MsgBox "ok"

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2020
    Posts
    1,635

    Re: HOW TO run sql by adodc1,use adCmdStoredProc?

    Code:
    Dim Rs As ADODB.Recordset
    Dim cmd As ADODB.Command
    Set cmd = New ADODB.Command
    Set cmd.ActiveConnection = Adodc1.Recordset.ActiveConnection
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = "deleteAll"
    Set Rs = cmd.Execute
    
    Adodc1.Recordset.Requery

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width