Bind an ado recordset directly to an ado data control (adodc) 
Author Message
 Bind an ado recordset directly to an ado data control (adodc)

Can an ado recordset be directly bound to an ado data control?  If so, how?


Tue, 18 May 2004 09:32:48 GMT  
 Bind an ado recordset directly to an ado data control (adodc)
Hi

Can't you just set the recordset property of the ado data control? The
following
code seems to work fine... Is this what you need, or am I missing something?

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset

' open data connection and open recordset
cn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & App.Path &
"\db1.mdb;"
rs.Open "select * from tblTest", cn, adOpenStatic, adLockReadOnly

Set Adodc1.Recordset = rs
Adodc1.Refresh

' display the nr of rows in the recordset
MsgBox Adodc1.Recordset.RecordCount

' kill objects
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing

Jurgen



Quote:
> Can an ado recordset be directly bound to an ado data control?  If so,

how?


Wed, 19 May 2004 06:04:47 GMT  
 Bind an ado recordset directly to an ado data control (adodc)
Yes, thanks.  I overlooked the "Set" keyword.  Duh!
Quote:

> Hi

> Can't you just set the recordset property of the ado data control? The
> following
> code seems to work fine... Is this what you need, or am I missing something?

> Dim cn As ADODB.Connection
> Dim rs As ADODB.Recordset

> Set cn = New ADODB.Connection
> Set rs = New ADODB.Recordset

> ' open data connection and open recordset
> cn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & App.Path &
> "\db1.mdb;"
> rs.Open "select * from tblTest", cn, adOpenStatic, adLockReadOnly

> Set Adodc1.Recordset = rs
> Adodc1.Refresh

> ' display the nr of rows in the recordset
> MsgBox Adodc1.Recordset.RecordCount

> ' kill objects
> rs.Close
> cn.Close
> Set rs = Nothing
> Set cn = Nothing

> Jurgen



> > Can an ado recordset be directly bound to an ado data control?  If so,
> how?



Sat, 22 May 2004 08:28:37 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Bound controls not updating ADO with adodc.recordset.update command

2. Data bound controls using Adodc and ADO connection object

3. Data Binding with ADODC y ADO DATAGRID

4. Data Binding with ADODC y ADO DATAGRID

5. First Cell Empty in Data Grid bound to ADO Data Control

6. Data Binding with an ADO recordset

7. Displaying ADO RecordSet in a Data Bound Grid?

8. ADO Data Control and Bound Controls

9. ADO Data Control and Bound Controls

10. Changing the source on an ADO recordset bound to controls

11. Problems with ADODB.Recordset objects and with the ADODC data control (recordset property) [Specificially when assigning a dynamically created RS to the RS property of the ADO data control]

12. Error 91 when trying to bind an ADO Recordset to an MSFlexGrid Control

 

 
Powered by phpBB® Forum Software