Posted by: Sourav | March 25, 2015

Find the next employee ID using Visual Basic 2012 in 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”)
        ‘MessageBox.Show(“Connection successful”, “PMS”)

        Dim mycommand As OleDbCommand
        mycommand = myconn.CreateCommand()
        mycommand.CommandText = “select max(EmployeeID) +1 from EmployeeMaster”
        Dim nextempID As Object = mycommand.ExecuteScalar()
        MessageBox.Show(“The next employee Id is ” & nextempID)

    End Sub
End Class


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s


%d bloggers like this: