ADO DataCombo Bind to a Recordset. 
Author Message
 ADO DataCombo Bind to a Recordset.

Hi there,

    I am having trouble to set the data from an ADO recordset of an SQL
connection into the DBcombo. It seems, from the article Q189682, that it is
possible to bind the combo to a recodset at run time. I've been trying to do
this following the article's example but without any success. The point is
that I don't get any error from the neither the compiler nor the system so
maybe I am forgeting an small tiny issue. The fact is that I have read the
MSDN information about the control and there is specified that the Rowsource
must be an ADO Data Control instead of a Recordset so I am a bit mess up....

The code I have been using is something like this:

Dim cn as ADODB.connection
Dim rs as ADODB.recordset
Dim rs2 as ADODB.recordset

cn.connectionstring="driver={SQL
Server};server=myserver;uid=sa;pwd=pwd;database=mydata"
cn.open

rs.open "SELECT * FROM [user];",cn
rs2.open "SELECT * from [connected];",cn

dbcombo.DataField="userid"
dbcombo.BoundColumn="userid"
dbcombo.ListField="username"

set dbcombo.rowsource=rs
set dbcombo.datasource=rs2

If I just change the line      set dbcombo.rowsource=rs  by set
dbcombo.rowsource=adodc1 (which is bound to rs) it works fine.... but I
still want to do it with the recordset is it is possible.

Hope I am doing a silly thing.
tah,
Ricardo Gandia



Mon, 04 Aug 2003 15:08:26 GMT  
 ADO DataCombo Bind to a Recordset.
This subroutine takes the DataCombo object as a parameter and binds it to a
rs.  I am not sure if this is what you are trying to do since I see 2
recordsets in your code and I getting all my data from one RS.  The only
other difference I see is that my objRS.CursorLocation is set to
"adUseClient."  I had the same problem with binding datalist/datacombo
controls where I would get no error, my RS had records in it, but my combo
was empty.  After I changed my CursorLocation property it worked like a
charm.

---------------------------------------------
'This sub is used from a class so it is public. Also
'the connection object is a private member variable of the class
'Ryan Jameson - Customer FX Corporation

Public Sub PopulateUserList(objDCombo As DataCombo)
Dim objRS As New ADODB.Recordset

    'Open RS
    objRS.CursorLocation = adUseClient
    objRS.Open "Select * from [USERINFO]", m_objCon

    'Bind DataCombo
    With objDCombo
        Set .DataSource = objRS
            .BoundColumn = "USERID"
        Set .RowSource = objRS
            .ListField = "USERNAME"
    End With

    'Clear RS object
    Set objRS = Nothing
End Sub
--------------------------------------------
Good Luck,

Ryan Jameson
Application Developer
Customer FX Corporation
www.customerfx.com



Tue, 05 Aug 2003 02:28:14 GMT  
 ADO DataCombo Bind to a Recordset.
It matters which order you set things:

   With dbcombo
      Set .DataSource = rs
      .DataField = "userid.
      .BoundColumn = "userid"
      Set .RowSource = rs2
      .ListField = "username" .
   End With

-Steven Elliott


Quote:
> Hi there,

>     I am having trouble to set the data from an ADO recordset of an SQL
> connection into the DBcombo. It seems, from the article Q189682, that it
is
> possible to bind the combo to a recodset at run time. I've been trying to
do
> this following the article's example but without any success. The point is
> that I don't get any error from the neither the compiler nor the system so
> maybe I am forgeting an small tiny issue. The fact is that I have read the
> MSDN information about the control and there is specified that the
Rowsource
> must be an ADO Data Control instead of a Recordset so I am a bit mess
up....

> The code I have been using is something like this:

> Dim cn as ADODB.connection
> Dim rs as ADODB.recordset
> Dim rs2 as ADODB.recordset

> cn.connectionstring="driver={SQL
> Server};server=myserver;uid=sa;pwd=pwd;database=mydata"
> cn.open

> rs.open "SELECT * FROM [user];",cn
> rs2.open "SELECT * from [connected];",cn

> dbcombo.DataField="userid"
> dbcombo.BoundColumn="userid"
> dbcombo.ListField="username"

> set dbcombo.rowsource=rs
> set dbcombo.datasource=rs2

> If I just change the line      set dbcombo.rowsource=rs  by set
> dbcombo.rowsource=adodc1 (which is bound to rs) it works fine.... but I
> still want to do it with the recordset is it is possible.

> Hope I am doing a silly thing.
> tah,
> Ricardo Gandia



Wed, 06 Aug 2003 10:27:21 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Bind an ado recordset directly to an ado data control (adodc)

2. Navigating through Recordsets using DataCombo (ADO)

3. ADO Recordsets and DataCombos

4. ADO recordset position and datacombo ctrl.

5. Navigating through Recordsets using DataCombo (ADO)

6. DataCombo box using ADO recordset

7. Populating a DataCombo Box with ADO RecordSet

8. URGENT MICROSOFT SUPPORT ISSUE - using ADO recordsets bound to Access .mbd Formsat runtime

9. ADO 2.7 recordset binding

10. Data Binding with an ADO recordset

11. Combo box bound to ADO recordset object?

12. Binding The DataGrid With ADO Recordset

 

 
Powered by phpBB® Forum Software