Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    7

    Smile Unanswered: ADO DAO questions

    This might be a silly question for some of you guys...

    In the VB window ->tools->reference, I have both activeX Data Objects 2.1 and dao 3.6 clicked... does it matter which one is first?

    And since I have both which one is it using as a default if I don't explicitly declare what kind of connection. For example:

    Dim str_num
    Dim dbs
    Dim rdset

    str_num = "Select [Addresses].[contact_id] from Addresses where [Addresses].[Default] = yes AND contact_id =" & Forms!frmClient_Add_PCP!ClientID
    Set dbs = CurrentDb()
    Set rdset = dbs.openRecordset(str_num)
    If rdset.EOF Then
    .
    .
    .
    'Blah Blah Blah
    .
    .
    .
    End If
    rdset.Close
    Set rdset = Nothing

    Should I have explictly declare an ADO or DAO connection? Is there any harm in not declaring it explicitly?

    TIA

  2. #2
    Join Date
    Aug 2003
    Location
    Massachusetts, USA
    Posts
    2

    Re: ADO DAO questions

    Originally posted by syndee
    This might be a silly question for some of you guys...

    In the VB window ->tools->reference, I have both activeX Data Objects 2.1 and dao 3.6 clicked... does it matter which one is first?

    And since I have both which one is it using as a default if I don't explicitly declare what kind of connection. For example:

    Dim str_num
    Dim dbs
    Dim rdset

    str_num = "Select [Addresses].[contact_id] from Addresses where [Addresses].[Default] = yes AND contact_id =" & Forms!frmClient_Add_PCP!ClientID
    Set dbs = CurrentDb()
    Set rdset = dbs.openRecordset(str_num)
    If rdset.EOF Then
    .
    .
    .
    'Blah Blah Blah
    .
    .
    .
    End If
    rdset.Close
    Set rdset = Nothing

    Should I have explictly declare an ADO or DAO connection? Is there any harm in not declaring it explicitly?

    TIA

    Yes, there is a difference. Whenever a method, property, object, etc. is part of mutilple references (as a recordset is ADO and DAO), the reference which is listed first will be the one used. The order of the list really represetns the priority of the references.

    If you list Active X first, you will default to ADO for most data access. When you need to be certain that the reference you want is the one which will be used - and it's not the default, you must specify enough of the full name to distinguish it.

    So if you want a DAO recordset with ADO as default, use "DAO." as the prefix. Use "ADODB." when DAO is the default.

  3. #3
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447

    Re: ADO DAO questions

    The problem is even worse, since DAO is the default data access reference in MS Access 97, and ADO in MS Access 2K. I saw a lot of '97 applications, which were upsized to 2K, and - surprisingly - didn't work anymore. So, it's also a good programming style to declare a variable not as you did:

    dim rdset


    but:
    dim rdset as ADODB.RecordSet

    Moreover, you make the life of the support team of your application easier, when they can see from the declaration, what type a variable has.
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

Posting Permissions

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