Load a entire column into a combo box

darkfreedom

Member
Joined
Aug 30, 2006
Messages
9
Programming Experience
Beginner
Hi, i am new to ADO.NET!!

How am I to retrieve an entire column from a table of a MS Access database into a combo box using DataAdapters, DataReaders, etc !! I need code..

Thanks,
Ray


PS: I'm using VB.NET 2003.
 
Oh, well that's easier than. I thought you wanted to combine different columns from each row into just one column.

Here's how you do it:
  1. Go to the "Data Sources" tool window.
  2. Expand the table you want to get the data from.
  3. Highlight the column you want to be made into a combobox.
  4. Click the arrow to the right of the selection and select "ComboBox".
  5. Drag and drop the column onto the form.
  6. Click the tiny black-on-white arrow toward the top-right of the combobox and check "Use data bound items".
  7. Bind the combobox to the column in the table.
 
Populating a combo box

am populating a combo box in ado.net as below

Dim myAda As New SqlDataAdapter
Dim DS As New DataSet
Dim DR1 As DataRow

myAda = New SqlDataAdapter("select * from CustomerDetails", myCon)
myAda.Fill(DS, "customerdetails")

cbFHOLDER.DataSource = DS.Tables("CustomerDetails")
cbFHOLDER.DisplayMember = "name"
cbFHOLDER.ValueMember = "pid"


Here cbFHOLDER is the combo box and myCon is the variable used for Connecting to MS-ACCESS. ( I think you must have already connected)
Display member will help to display the column you want
value member will help to sort out the order of the column.

Let me know if the above works
Regards
CMR
 
I think Berry-tan uses the simple drag-and-drop method (so its name is visual programming) and made VS.NET creates all required data-access objects automatically (OledbConnection, OledbDataAdapter, and DataSet). You will find these objects on the component tray of VS.NET.

Cmr creates all data-access objects. Mastering the way that Cmr wrote will clear what Berry-tan did.

Thank's
Inhua
 
i got it, its working....... thanx

now how can i do d other way around.... like modify data of a specific field if d table of a specific row, from string typed on a textbox.
 
Kindly elaborate a little more.
Do you want to update(modify) a field?

And which way did you populate the combo like berry-tan or mine.

Thanks
Cmr
 
yes, i want to modify a specific field with new data. Not all d values, but a specific row.

I would like to populate it like u (to Cmr) have done it, i.e. programically

thanks!!
 
Back
Top