Results 1 to 4 of 4

Thread: MS Access and Combo Box

  1. #1

    Thread Starter
    Lively Member Cagez's Avatar
    Join Date
    Oct 2002
    Posts
    121

    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.

  2. #2
    Lively Member
    Join Date
    Jan 2002
    Posts
    105
    Just a quick note....it would help if you posted the code you've got and someone could check where you've gone wrong.

  3. #3

    Thread Starter
    Lively Member Cagez's Avatar
    Join Date
    Oct 2002
    Posts
    121
    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?

  4. #4
    Member
    Join Date
    Dec 2002
    Location
    NY, USA
    Posts
    52
    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
    Iouri Boutchkine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width