Results 1 to 2 of 2

Thread: populating combo thro' ado.net thro' coding

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2002
    Posts
    24

    Smile populating combo thro' ado.net thro' coding

    Hello Everybody!!
    Well, I have to populate a combobox from an access database.
    I can do it using server explorer.and it is working fine.
    But when i do it with coding (ie creating connection,connstring,command etc),when i set Data source and Display name preoperty of combo in coding it gives me an error saying
    'COMPLEX DATA BINDING ACCEPTS AS A DATASOURCE EITHER AN ILIST OR ILISTSOURCE'
    (The same 2 properties r to be set while using server explorer as well.)
    Can anyone tell me what does this mean and what should i do abt it?
    Luv
    Amita

  2. #2
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651
    Amita
    Try this
    VB Code:
    1. Private Sub PopulateCustCombo()
    2.         Dim myconn As New SqlConnection(CON_STRING)
    3.         Dim dsCust As New DataSet()
    4.         Dim mysqladapter As New SqlDataAdapter()
    5.         myconn.Open()
    6.         mysqladapter = New SqlDataAdapter("SELECT CustomerID, ContactName FROM Customers", myconn)
    7.         mysqladapter.Fill(dsCust, "customer")
    8.         With cboCustomerID
    9.             .DataSource = dsCust.Tables("customer")
    10.             .DisplayMember = "CustomerID"
    11.         End With
    12.         myconn.Close()
    13.     End Sub
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

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