Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2009
    Posts
    85

    Unanswered: ADO connection and class mod

    Hello, can some one say if it make since to put the following code in a class module

    'Declaire connection object variable
    Dim cnn As ADODB.Connection

    'Set current Access connection to Connection object Variable
    Set cnn = CurrentProject.Connection

    Dim rs As New ADODB.Recordset
    rs.ActiveConnection = cnn

    Dim aSQL as String
    Dim bSQL as String
    Dim cSQL as String

    I cant tell if this is un-wise or just plain dumb, thanks

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    It's not plain dumb, but so far with the code you have produced it looks unnecessary.

    I confess I don't bother all that much with objects in VBA. I use a standard module for my data access stuff. In C# I do have a load of classes for a DAL.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    depends on how you plan using the objects
    by defintion you are decalring them as global objects within the scope of that module. so providing you don't allow more than one section of code using them I don't see a problem

    I think there could well be a problem if you use the same recordset between various sections of the same instance of the module.

    you aren't really going to save anything by decalring the connection, as in most instances of the ADODB objects the current connection is deemed to be the default

    used wisely I don't think its a problem, it just looks nasty, it has the scope to be abused

    one other point is that if the code breaks or resets you will have problems with the objects being unset
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Apr 2009
    Posts
    85
    poodle flump, healdem thanks for your response, I think I will refrain from doing this, seems like to much room for error.

Posting Permissions

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