Posted by: Sourav | March 25, 2015

Data Reader Object in Visual Basic 2012 and access


Imports System.Data.OleDb

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim myconn As OleDbConnection
        myconn = New OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\PMS.MDB”)
        myconn.Open()
        ‘MessageBox.Show(“Connection successful”, “PMS”)

        Dim mycommand As OleDbCommand
        mycommand = myconn.CreateCommand()
        mycommand.CommandText = “select EmployeeID,FirstName,MiddleName,LastName from EmployeeMaster”

        Dim myReader As OleDbDataReader
        myReader = mycommand.ExecuteReader()
        While (myReader.Read())
            MessageBox.Show(“EmployeeID: ” & myReader.Item(“EmployeeID”).ToString() + vbCrLf + “FullName: ” & myReader.Item(“FirstName”).ToString() & ” ” & myReader.Item(“MiddleName”).ToString() & ” ” & myReader.Item(“LastName”).ToString())

        End While

        Me.Close()

    End Sub
End Class

Advertisements

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

Categories

%d bloggers like this: