473,412 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Filling a combo box

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 ?
Feb 13 '07 #1
6 2707
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

"giannis" <zz********@freemail.grwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
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 ?

Feb 14 '07 #2
Tiago Salgado wrote:
You need something like this:

Dim da as SqlDataAdapter
I receive the error "Type SqlDataAdapter is not defined "
Feb 14 '07 #3
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.
------------------------------
"giannis" <zz********@freemail.grwrote in message
news:ua****************@TK2MSFTNGP04.phx.gbl...
Tiago Salgado wrote:
>You need something like this:

Dim da as SqlDataAdapter

I receive the error "Type SqlDataAdapter is not defined "

Feb 14 '07 #4
you need to not use DOTNET

Microsoft is going to invent visual fred again this summer


On Feb 13, 12:11 pm, "giannis" <zzzinob...@freemail.grwrote:
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 ?

Feb 14 '07 #5
Tiago Salgado wrote:
You need something like this:

Dim da as SqlDataAdapter= New SqlDataAdapter("SELECT ID,Name FROM
Table", your_db_conn)
My Dataset is a mdb database. What must i write as "your_db_conn" ?
Feb 14 '07 #6

"giannis" <zz********@freemail.grwrote in message
news:OI**************@TK2MSFTNGP04.phx.gbl...
Tiago Salgado wrote:
>You need something like this:

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

My Dataset is a mdb database. What must i write as "your_db_conn" ?
It's your connection to the database.

Robin S.
Feb 14 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: -elniniol999- | last post by:
I am DESPERATE for a quick reply.. have exhausted my options... i have a table called order details which contains: order id product id product name quantity unit price sale price
1
by: JRT | last post by:
I have a continuous form with 3 comboxes, combo1, combo2 combo3. The choices in combo2 are dtermined the what is selected in combo1 by using a where = combo1 statement. The combo is refreshed...
6
by: Brian | last post by:
Hello, Basically, I'm running a query on a form's activation, and I'd like to have the results of the query be placed into other fields on the same form automatically. Does anybody know how...
2
by: ramesh | last post by:
hi, I am using Com+ in my application. It will have InsertRecords,selectRecords,updateRecords function. In the Web Form i have Drop-down list. I want to select records from SQL and add it to this...
5
by: Dave | last post by:
How would I go about filling a combo box with some existing enumeration values? Can I bind it to the enumeration? Then, once the selection is made from the combo box, set a property to the...
2
by: fstenoughsnoopy | last post by:
I have a customer order database and I need to pull a customers information, ie first name, last name, address, city, state, zip, phone, etc, into the oder table. i don't know how to go about...
1
by: jason.teen | last post by:
Hi, Just wondering if you can mix values in a combo box. I want to fill it up with some query such as: select name from tblDetails; and that may produce a combo box with: "John" "Peter"
3
by: wideasleep | last post by:
I have a subform that's a continuous form. In it I have a combo box that fills a date field. It works great except for one thing. It fills in all the other date fields for each record and the combo...
5
by: punitshrivastava | last post by:
Hi to all, I am punit.i m working in php.As i m fresher in php .i am using combo box for selection of data & making Report .please tell me that how i fill the combo box dynamically.so please suggest...
4
by: ibrahim2008 | last post by:
I am trying to fill data in a combo box(comwork) from a record set,but that record set is retrieving nearly 44000 records.While executing this error is coming,"invalid item index."i think that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.