0% found this document useful (0 votes)
30 views2 pages

B

This document provides a VB.Net program to accept employee details like employee number, name, and salary from text boxes. It stores the data in an Access database and displays it on a data grid view. The program imports necessary namespaces, declares variables to connect to the database and execute commands, and has methods to display existing data and insert new data on a button click event.

Uploaded by

Rohit Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

B

This document provides a VB.Net program to accept employee details like employee number, name, and salary from text boxes. It stores the data in an Access database and displays it on a data grid view. The program imports necessary namespaces, declares variables to connect to the database and execute commands, and has methods to display existing data and insert new data on a button click event.

Uploaded by

Rohit Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

B) Write a VB.

Net program to accept the details of Employee (ENO, EName Salary)

and store it into the database and display it on gridview control.

Answer

Imports System

Imports System.Data

Imports System.Data.OleDb

Public Class Form1

Dim con As New OleDbConnection(Provider=Microsoft.ACE.OLEDB.12.0;Data


Source=CUsersDesktopNew folderEmp.accdb)

Dim adpt As New OleDbDataAdapter(Select from Emp, con)

Dim ds As New DataSet

Dim cmd As New OleDbCommand

Public Function display()

adpt.Fill(ds, Emp)

DataGridView1.DataSource = ds

DataGridView1.DataMember = Emp

Return ds

End Function

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

display()

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click

cmd.Connection = con

cmd.CommandType = CommandType.Text

cmd.CommandText = insert into Emp values( & TextBox1.Text & ,' &
TextBox2.Text & ', & TextBox3.Text & )

con.Open()

cmd.ExecuteNonQuery()

con.Close()
ds.Clear()

display()

End Sub

End Class

You might also like