Results 1 to 2 of 2

Thread: ADO Connection With Table Indexes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Location
    Ontario, Canada.
    Posts
    85

    Question

    I want to use an ADO connection to an Access 2000 database but I don't want to use SQL to make the connection. I want to use the tables index to sort the records and make the connection. I've tried this:

    Set dbConnect = New ADODB.Connection
    With dbConnect
    .ConnectionString= "Provider=Microsoft.JET.OLEDB.4.0; Data Source=" & dbLocation
    .CursorLocation = adUseClient
    .Open
    End With

    recSet.Open "table",dbConnect,adOpenKeyset,adLockOptimistic, adCmdTableDirect

    recSet.Index = "tableIndex"

    But This will not work.

    With DAO this would work will no problems. Any idea???

    Thanx in Advance.



  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    here ya go

    Code:
        Dim rs As Recordset
        Dim cn As Connection
        Dim fld As Field
        
        Set cn = New Connection
        Set rs = New Recordset
        
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=NWind2k.mdb"
        
        With rs
            .ActiveConnection = cn
            .Source = "Customers"
            .CursorLocation = adUseClient
            .CursorType = adOpenKeyset
            .Open
            
            Set fld = .Fields("CustomerID")
            fld.Properties.Item("Optimize").Value = True
            
            .Find "CustomerID = 'FRANR'"
                    
            If .RecordCount > 0 Then
                MsgBox "Found!"
            Else
                MsgBox "Not Found!"
            End If
                
        End With

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