Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2006, 01:33 AM
Authorized User
 
Join Date: Aug 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to amit_mande@yahoo.com Send a message via AIM to amit_mande@yahoo.com Send a message via MSN to amit_mande@yahoo.com Send a message via Yahoo to amit_mande@yahoo.com
Default how to dispaly data in combobox from access?

I have one Database ,in which there is one table employee .I want to fetch data from table Department and want to display in combobox cmbDept.

 
Old September 28th, 2006, 05:06 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

If the only table is employee, you'll have a lot of trouble fetching data from one named Department.

(Note: Punctuation follows immediately after the word, then a space, then the rest of the sentence. I have noticed that most individuals who post from India invert that, with word, then space, then punctuation. Is there a reason stemming from the native language/text that is used in India?)
 
Old October 16th, 2006, 11:31 PM
Registered User
 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dim conn as new sqlclient.sqlconnection
dim cmd as new sqlclient.sqlcommand
dim dr as sqlclient.sqldatareader
//define above code globely//

form_load event()
conn.connectionstring="type your connection string here"
cmd.connection=conn
conn.open()
cmd.commandtext="select * from employee"
combobox1.items.clear
combobox1.items.add("")
dr=cmd.executeReader
while dr.read()
combobox1.items.add(dr(0))
end while
dr.close
conn.close
//plz type this code on form load event and tyr//


 
Old October 16th, 2006, 11:35 PM
Registered User
 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

imports system.data.oledbclient
dim conn as new oledbclient.oledbconnection
dim cmd as new oledbclient.oledbcommand
dim dr as oledbclient.oledbdatareader
//define above code globely//

form_load event()
conn.connectionstring="type your connection string here"
cmd.connection=conn
conn.open()
cmd.commandtext="select * from employee"
combobox1.items.clear
combobox1.items.add("")
dr=cmd.executeReader
while dr.read()
combobox1.items.add(dr(0))
end while
dr.close
conn.close
//plz type this code on form load event and tyr//

 
Old October 30th, 2006, 09:11 AM
Registered User
 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you have an OleDb Connection :

Dim daEmp as New OleDb.OleDbDataAdapter("SELECT employee FROM Department", connEmp)
Dim dsEmp as New DataSet
daEmp.Fill(dsEmp,"EmpTable")
Dim rowEmp as DataRow
For Each rowEmp in dsEmp.Tables("EmpTable").Rows
   cmbDept.Items.Add(rowEmp("employee"))
Next

That would populate the ComboBox with the Employee data in the Department table.

Hope it helps you :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Data in combobox sathishr Excel VBA 1 January 2nd, 2007 06:35 AM
dispaly specific data from access datbase priyankkgupta Classic ASP Basics 3 December 1st, 2006 10:35 PM
Restricting the data in a ComboBox hemanth_p2p Visual Basic 2005 Basics 2 January 10th, 2006 02:23 AM
data binding a combobox ozPATT Excel VBA 1 November 16th, 2005 08:17 AM
data access page - combobox ausir007 Access VBA 4 April 26th, 2005 06:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.