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=i tregister; pwd=%T6y7u 8i9o;datab ase=itregi ster"
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.ValueMembe r = rsCompany.Fields("CompanyR ef").Value
comboboxCompany.DisplayMem ber = rsCompany.Fields("CompanyN ame").Valu e
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?
Dim db As New ADODB.Connection
Dim dbConString As String = "Provider=sqloledb;server=
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.ValueMembe
comboboxCompany.DisplayMem
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?
Add this too
comboboxCompany.DataSource = rsCompany
comboboxCompany.DataSource
ASKER
I did try that but i got the following error
Complex DataBinding accepts as a data source either an IList or an IListSource
Complex DataBinding accepts as a data source either an IList or an IListSource
comboboxCompany.DataSource = rsCompany.Tables(0)
ASKER
Now i get
Public member 'tables' on type 'RecordSetClass' not found
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.
Check this out:
http://msdn.microsoft.com/en-us/library/aa720078%28VS.71%29.aspx
I hope this helps.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is the problem sorted?
ASKER
Yes
ASKER