Link to home
Start Free TrialLog in
Avatar of ict-torquilclark
ict-torquilclark

asked on

ADODB.RecordSet and Combobox's

I have the following code to create a record set in a form

Dim db As New ADODB.Connection
Dim dbConString As String = "Provider=sqloledb;server=sql1;uid=itregister;pwd=%T6y7u8i9o;database=itregister"
db.Open(dbConString)

Dim rsCompany As New ADODB.Recordset
rsCompany.Open("SELECT * FROM Company", db)


I want to set the properties of a combobox using this recordset. I have used the following code

comboboxCompany.ValueMember = rsCompany.Fields("CompanyRef").Value
comboboxCompany.DisplayMember = rsCompany.Fields("CompanyName").Value

When i testand i click the dropdown arrow on the combobox nothing happens. I am new to using ADODB i have always used tableadapters. What am i doing wrong?

Avatar of ict-torquilclark
ict-torquilclark

ASKER

This code is in the Form load even
Add this too

comboboxCompany.DataSource = rsCompany
I did try that but i got the following error

Complex DataBinding accepts as a data source either an IList or an IListSource
comboboxCompany.DataSource = rsCompany.Tables(0)
Now i get

Public member 'tables' on type 'RecordSetClass' not found
Just a suggestion, why don't you convert your RecordSet into a Dataset and then use this DataSet as your data source, so that you would not get the IList/IListSource issue.

Check this out:

http://msdn.microsoft.com/en-us/library/aa720078%28VS.71%29.aspx

I hope this helps.
Avatar of Carl Tawn
This might be a daft question, but if you've been using TableAdapters before, why are you now taking a step back and using ADODB?
Yeah.  I agree with @carl_tawn.  Why are you still using ADODB when there are other powerful data access tools available in .NET and since you are using TableAdapters already?
ASKER CERTIFIED SOLUTION
Avatar of ict-torquilclark
ict-torquilclark

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is the problem sorted?