Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Location
    Romania
    Posts
    70

    Unanswered: MS SQL + ADO + VB6, Which is the best method ?

    First, sorry for my english

    In vb.6 I use 2 DataCombo and 1 DataGrid in 1 Form, totally I need 3 recordset on 1 form.

    All 3 recordset is from MS SQL Server in one database.

    Which is the best method ?

    1. To place 3 ADODC control on the form and for each

    ADODC1.ConnectionString="......................... ...."
    ADODC1.RecordSource="SELECT * FROM Table1"

    ADODC2.ConnectionString = the same as ADODC 1
    ADODC2.RecordSource="SELECT * FROM Table2"

    ADODC3.ConnectionString = the same as ADODC 1
    ADODC3.RecordSource="SELECT * FROM Table3"

    OR

    2. I don't use ADODC control, I use a single connection and 3 Recordset

    Set cn = New ADODB.Connection

    With cn
    .ConnectionString = "............."
    .Open
    End With

    Dim Rec1 As New ADODB.Recordset
    With Rec1
    .Open "SELECT * FROM Table1, cn, adOpenStatic, adLockReadOnly
    End With

    Dim Rec2 As New ADODB.Recordset
    ....................................
    Dim Rec3 As New ADODB.Recordset
    .......................................

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    The single connection object with multiple recordset objects is the better choice. Also, make sure you use the SQLOLEDBXX provider in your connection string.

  3. #3
    Join Date
    Feb 2002
    Posts
    2,232
    Another comment - declare your objects at the top of your code so

    Dim cn as adodb.connection
    dim rs1 as adodb.recordset
    dim rs2 as adodb.recordset ...

    Then instantiate the recordset object as late as possible in your code (stay away from dim as new) and destroy the object as soons as possible:

    set rs1 = new adodb.recordset
    'start recordset manipulation
    'end recordset manipulation
    set rs1 = nothing

Posting Permissions

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