|
-
Jan 21st, 2003, 03:29 AM
#1
Thread Starter
Junior Member
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
-
Jan 22nd, 2003, 08:32 AM
#2
Fanatic Member
Amita
Try this
VB Code:
Private Sub PopulateCustCombo()
Dim myconn As New SqlConnection(CON_STRING)
Dim dsCust As New DataSet()
Dim mysqladapter As New SqlDataAdapter()
myconn.Open()
mysqladapter = New SqlDataAdapter("SELECT CustomerID, ContactName FROM Customers", myconn)
mysqladapter.Fill(dsCust, "customer")
With cboCustomerID
.DataSource = dsCust.Tables("customer")
.DisplayMember = "CustomerID"
End With
myconn.Close()
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|