|
-
Feb 22nd, 2003, 07:11 PM
#1
Thread Starter
Lively Member
MS Access and Combo Box
I have a MS Access db with table 'users' and I want to populate the combo box with the user names from the db (field 'user') from the table.
I have a connection, a data adapter and a data set, but whenever I set DataSource and DisplayMember of my combo box, I try it out and nothing appears.
Any idea what the problem can be - or point me in the direction of a tutorial, I've done this purely through VB.net docs and an modified example from these forums.
Thank you!
Last edited by Cagez; Feb 23rd, 2003 at 10:09 AM.
-
Feb 23rd, 2003, 05:45 AM
#2
Lively Member
Just a quick note....it would help if you posted the code you've got and someone could check where you've gone wrong.
-
Feb 23rd, 2003, 10:08 AM
#3
Thread Starter
Lively Member
I was thinking about that, but I didn't do it through code, I did it through the designer (Toolbox->Data->OleDbConnection/OleDbAdapter/DataSet)... Should I do it the other way?
-
Feb 23rd, 2003, 11:06 AM
#4
Member
Create a dataset from your table and then populate the combo from the required field
Code:
Dim cnNorthwind As New SqlConnection("Data Source=localhost;Integrated
Security=SSPI;Initial Catalog=northwind")
Dim cmCustomers As New SqlCommand("uspS_Company", cnNorthwind)
Dim daCustomers As New SqlDataAdapter(cmCustomers)
Dim dsCustomers As New DataSet()
Dim drCustomers As DataRow
'fill DataSet
daCustomers.Fill(dsCustomers, "Customers")
'adding items with DataRow from DataSet
For Each drCustomers In dsCustomers.Tables("Customers").Rows
cbo.Items.Add(drCustomers("CompanyName"))
Next
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|