Displaying data in a DataGrid in VB.NET 2005

I am using ms access for my database.I have a students table in my database where student name, roll, mobile, email.I Create a VB.NET form and I have placed a datagridview in the form. When i click View all Button then all information of student table show in the datagridview.

Used Name Space:

Imports System.data.oledb

My Project Code:

Private Sub view_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles view.Click

Dim str, str1 As String
Dim con As OleDbConnection
str = “Provider=Microsoft.Jet.oledb.4.0;Data Source=C:\\student.mdb;” con = New OleDbConnection(str)
Dim da As OleDbDataAdapter
Dim tb As DataTable
str1 = “select name,roll,mobile,email from students”
da = New OleDbDataAdapter(str1, con)
tb = New DataTable(“student”)
DataGridView1.DataSource = tb
Catch ex As OleDbException
MsgBox(ex.Message, MsgBoxStyle.Critical, “Oledb Error”)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, “General Error”)
End Try

4 responses to this post.

  1. Sobuj vai kemon asen?
    apner khobor ki ? kothao join koresen ki ? korle janaben,
    apner valo kamonai sotovai


  2. Posted by aziz on June 23, 2008 at 10:53 pm



  3. Posted by shuvo on March 30, 2011 at 5:28 pm

    A lot of thanks for such kind of great effort. This kind of tutorial is really helpful for beginner level programmer. Hope you will upload more.


  4. Hi
    Your Example is so good and also help full for me thanks a lot

    Tamil Nadu


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 416 other followers

%d bloggers like this: