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
..............................The single connection object with multiple recordset objects is the better choice. Also, make sure you use the SQLOLEDBXX provider in your connection string.|||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
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment