.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 Your Table Data In Your Grid view

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

Code To Bind All Data In Your Grid view...
 


Public Sub Bind()
	OleDbConnection Conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/MyDatabase1.mdb");
        	Try
            		Conn.Open()
            		Dim cmd As New OleDbCommand("SELECT * FROM Student", Conn)
            		Dim ds As New DataSet()
            		Dim adp As New OleDbDataAdapter(cmd)
            		adp.Fill(ds)
            		DataGridView1.DataSource = ds.Tables(0)
        	Catch ex As Exception
            		MessageBox.Show(ex.ToString())
        	Finally
            		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