DAO to ADO

Discussion in 'AutoCAD' started by media, Apr 13, 2004.

  1. media

    media Guest

    Can some body help me to "convert" this DAO code to ADO code?

    dbname = txtChemin.Text
    Set dbs = wks.OpenDatabase(dbname)
    Dim recset1 As Recordset
    Set recset1 = dbs.OpenRecordset("catalogue1")
    recset1.MoveLast
    recset1.MoveFirst

    recset1.FindFirst "code=" & valcode
    If recset1.NoMatch = True Then
    MsgBox "pas de donnees"
    end if


    thanks
     
    media, Apr 13, 2004
    #1
  2. media

    Luis Alberto Guest

    It would be like this:

    Dim dbs As New ADODB.Connection
    Dim recset1 As New ADODB.Recordset
    Dim dbname As String
    Dim valcode As Integer

    dbname = txtChemin.Text
    dbs.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & dbname
    recset1.Open "catalogue1", dbs, adOpenDynamic, adLockOptimistic
    'recset1.MoveLast 'You do not need this line of code.
    'recset1.MoveFirst 'You do not need this line of code.

    recset1.Filter = "code=" & valcode
    If recset1.BOF And recset1.EOF Then
    MsgBox "pas de donnees"
    End If

    recset1.Close
    Set recset = Nothing
    dbs.Close
    Set dbs = Nothing
     
    Luis Alberto, Apr 14, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.