.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Bind Field Data Into The Combobox

Posted By:Ghanashyam Nayak       Posted Date: January 31, 2011    Points: 15    Category: Windows Form Controls    URL: http://www.dotnetspark.com  

Code To Bind All Field Data In Your Combobox...
 


Public Sub ComboboxBind()
	OleDbConnection Conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/MyDatabase1.mdb");
        	Try
		Conn.Open()
		Dim cmd As OleDbCommand = New OleDbCommand("Select StudentName From Student", Conn)
		dr = cmd.ExecuteReader
		While dr.Read()
			ComboBox1.Items.Add(dr.GetValue(0).ToString())
		End While
        	Catch ex As Exception
		MessageBox.Show(ex.ToString())
	Finally
		dr.Close()
		Conn.Close()
	End Try
End Sub


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend