Write VB.Net program to search employee record using emp_id or employee_name into database,display employee record in data grid.


Public Class Form1

Dim cn As OleDb.OleDbConnection

    Dim cmd As OleDb.OleDbCommand

    Dim ds As New DataSet

    Dim dap As OleDb.OleDbDataAdapter

    Dim cnt As Integer

    Dim str As String

    Dim cid As Integer

    Dim n As String

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        cn = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0.;Data Source=F:\T104\NET\Slip Solution VB.Net sem 5\slip13\emp.mdb")

        cn.Open()

        cid = InputBox("Enter no:")

        cmd = New OleDb.OleDbCommand("select * from em where eno=" & cid, cn)

        dap = New OleDb.OleDbDataAdapter(cmd)

        dap.Fill(ds)

        grid.DataSource = ds.Tables(0)

        cn.Close()

 End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        cn = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0.;Data Source=F:\T104\NET\Slip Solution VB.Net sem 5\slip13\emp.mdb")

        cn.Open()

        n = InputBox("Enter name:")

        cmd = New OleDb.OleDbCommand("select * from em where ename='" & n & "'", cn)

        dap = New OleDb.OleDbDataAdapter(cmd)

        dap.Fill(ds)

        grid.DataSource = ds.Tables(0)

        cn.Close()

    End Sub

End Class
Write VB.Net program to search employee record using emp_id or employee_name into database,display employee record in data grid. Write VB.Net program to search  employee record using emp_id or employee_name into database,display employee record in data grid. Reviewed by on April 27, 2015 Rating: 5
Powered by Blogger.