DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Counting records while using ADO EXECUTE command

  1. #1
    Sobrina Guest

    Counting records while using ADO EXECUTE command


    I have to use the ADO EXECUTE command so that I can use the timeout parameter.
    I'm using ACCESS 2000 along with EXCEL 2000.
    I then need to get the record count of the record set that returns from the
    command.

    I saw another post that was similar but the person was pointed to use the
    .open. I could not get the application to use a timeout parameter with the
    open.

    Any help would be greatly appreciated. The code is below.

    Dim rst As ADODB.Recordset
    Dim adoCMD As ADODB.Command
    Dim cnn As ADODB.Connection
    Dim strSQL As StringScreen.MousePointer = vbHourGlass

    strPlanGroupSQL = ""
    strPlanCodeSQL = ""
    strPlanGroupSQL = GetSelectedItem(lstPlanGroup)
    strSQL = strSQL + strProviderSQL + strPlanGroupSQL + ";"

    Set cnn = New ADODB.Connection
    cnn.Open gConnectionString

    Set adoCMD = New ADODB.Command
    adoCMD.ActiveConnection = cnn
    adoCMD.CommandTimeout = 400
    adoCMD.CommandType = adCmdText
    adoCMD.CommandText = strSQL

    Set rst = New ADODB.Recordset
    Set rst = adoCMD.Execute

    lstPlanCode.Clear
    Do While Not rst.EOF
    lstPlanCode.AddItem rst("Plan_Code") + vbTab + rst("Plan_Code_Name")
    rst.MoveNext
    Loop
    rst.Close
    Screen.MousePointer = vbDefault





  2. #2
    Guest

    Re: Counting records while using ADO EXECUTE command


    "Sobrina" <SobrinaB@aol.com> wrote:
    >
    >I have to use the ADO EXECUTE command so that I can use the timeout parameter.
    > I'm using ACCESS 2000 along with EXCEL 2000.
    >I then need to get the record count of the record set that returns from

    the
    >command.
    >
    >I saw another post that was similar but the person was pointed to use the
    >.open. I could not get the application to use a timeout parameter with

    the
    >open.
    >
    >Any help would be greatly appreciated. The code is below.
    >
    >Dim rst As ADODB.Recordset
    >Dim adoCMD As ADODB.Command
    >Dim cnn As ADODB.Connection
    >Dim strSQL As StringScreen.MousePointer = vbHourGlass
    >
    > strPlanGroupSQL = ""
    > strPlanCodeSQL = ""
    > strPlanGroupSQL = GetSelectedItem(lstPlanGroup)
    > strSQL = strSQL + strProviderSQL + strPlanGroupSQL + ";"
    >
    > Set cnn = New ADODB.Connection
    > cnn.Open gConnectionString
    >
    > Set adoCMD = New ADODB.Command
    > adoCMD.ActiveConnection = cnn
    > adoCMD.CommandTimeout = 400
    > adoCMD.CommandType = adCmdText
    > adoCMD.CommandText = strSQL
    >
    > Set rst = New ADODB.Recordset
    > Set rst = adoCMD.Execute
    >
    > lstPlanCode.Clear
    > Do While Not rst.EOF
    > lstPlanCode.AddItem rst("Plan_Code") + vbTab + rst("Plan_Code_Name")
    > rst.MoveNext
    > Loop
    > rst.Close
    > Screen.MousePointer = vbDefault
    >
    >
    >
    >

    I know that when using recordset that connection to database servers, you
    have to set the recordset cursor location to client. Otherwise, the recordcount
    of the recordset is -1. I have not tried it with Access and Excel, but you
    could give it a try.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center