Select to view content in your preferred language

Adodb - Count, Maximum, Minimum

1312
2
08-29-2011 11:50 AM
KarenGreen
Deactivated User
I have the below code that runs on data in the Oracle SDE.
I would like to run the same simple simple query on data in a file geodatabase, but I just get and error -2147467259 (80004005).
If I change the sql to take out the word "Count" then everything is fine.
I need to get Count, Maximum and Minimum from a Standalone table in a File Geodatabase.

Please help.
Thanks


Private Sub cmdCheck_Click()
    'error handler
    On Error GoTo EH

    Dim oConn As ADODB.Connection
    Dim strConnect As String
    Dim rs As ADODB.RecordSet
    Dim strSql As String
   
'   open the database
    Set oConn = New ADODB.Connection
    strConnect = "Provider=OraOLEDB.Oracle;" & frmMain.g_ADODataSource & _
                "User Id='" & frmMain.g_strDB & "';" & "Password='" & frmMain.g_strPW & "'"
    oConn.Open strConnect
   
'   create and run the query
    strSql = "select count(*) from mytablename "
    Set rs = New ADODB.RecordSet
    rs.Open strSql, oConn
    MsgBox rs(0).Value & " records"

    oConn.Close
   
    Exit Sub
   
EH:
    MsgBox "Error in Check " & vbCrLf & _
        Err.Description & vbCrLf & Err.Number


End Sub
0 Kudos
2 Replies
LanceShipman
Esri Regular Contributor
I'm sorry to say that Count, Min and Max are not currently available with a file geodatabase from the select list. They can be used in a limited way from a Sub Query. At ArcGIS 10.1 beta2 they will be available in the select list via a QueryDef.
0 Kudos
KarenGreen
Deactivated User
I'm sorry to say that Count, Min and Max are not currently available with a file geodatabase from the select list. They can be used in a limited way from a Sub Query. At ArcGIS 10.1 beta2 they will be available in the select list via a QueryDef.


Thanks Lance, I thought I was losing my mind
0 Kudos