Groups | Blog | Home
all groups > vb.net > february 2007 >

vb.net : Filling a combo box


RobinS
2/13/2007 9:53:26 PM
Be sure you have references set up correctly. You can import them at the
top of your routine.

Imports System.Data
Imports System.Data.SqlClient 'this is probably the one you're missing

Or double-click on "My Project", go to the "References" tab, and add them
there.

Robin S.
------------------------------
[quoted text, click to view]

giannis
2/13/2007 10:11:17 PM
Sorry because i dont speak english very well.
I am a newbie at VB and i have the bellow question:
How can i fill a combo box with data from a SQL clause ?
Can you explain me ? Is there any way to do this without code?
If need code , what code must i write ?

pfc_sadr NO[at]SPAM hotmail.com
2/13/2007 11:28:42 PM
you need to not use DOTNET

Microsoft is going to invent visual fred again this summer




[quoted text, click to view]

giannis
2/14/2007 12:00:00 AM
[quoted text, click to view]

I receive the error "Type SqlDataAdapter is not defined "

Tiago Salgado
2/14/2007 3:18:33 AM
You need something like this:

Dim da as SqlDataAdapter= New SqlDataAdapter("SELECT ID,Name FROM Table",
your_db_conn)
Dim ds As New DataSet

da.Fill(ds,"TableName")

combobox1.DataSource = ds
combobox1.ValueMember = "ID"
combobox1.DisplayMember = "Name"

Try something like this.


--

Tiago Salgado

http://weblogs.pontonetpt.com/tiagosalgado
http://www.foruns.org
http://www.portugal-a-programar.org
http://www.revista-programar.info

[quoted text, click to view]
RobinS
2/14/2007 9:25:24 AM

[quoted text, click to view]

It's your connection to the database.

Robin S.

giannis
2/14/2007 3:13:54 PM
[quoted text, click to view]

My Dataset is a mdb database. What must i write as "your_db_conn" ?

AddThis Social Bookmark Button