We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
GRAMIN TECHNICAL AND MANGEMENT CAMPUS
GRAMIN TECHNICAL AND MANGEMENT CAMPUS
DEPARTMENT OF COMPUTER ENGINEERING SUBJECT /CODE /:GAD 23034 Practical No 27 Name: suyash telang Roll No:- 41 DOP: DOS: CODE: Imports System.Data.OleDb Public Class Form1 Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Dim cnt As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\LAB - 2 PC - 20\Desktop\ expt27.mdb") cmd = New OleDbCommand cn.Open() cmd.Connection = cn cmd.CommandText = "INSERT INTO table1(id,name)values('" & TextBox1.Text & "','" & TextBox2.Text & "')" cmd.ExecuteNonQuery() cn.Close() MsgBox("Saved!!!", vbOK) End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button3.Click cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\LAB - 2 PC - 20\Desktop\expt27.mdb") cn.Open() cmd = New OleDbCommand("Delete from table1 where id=" & TextBox1.Text, cn) cmd.ExecuteNonQuery() 'not return values MessageBox.Show("record deleted") cn.Close() End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button4.Click cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\LAB - 2 PC - 20\Desktop\expt27.mdb") cmd = New OleDbCommand cn.Open() cmd.Connection = cn cmd = New OleDbCommand("update table1 set name='abc' where id=" & TextBox1.Text, cn) cmd.ExecuteNonQuery() 'not return values MessageBox.Show("record updated") cn.Close() End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click Dim ad1 As OleDbDataAdapter
Dim ds As New DataSet()
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ Users\LAB - 2 PC - 20\Desktop\expt27.mdb") ad1 = New OleDbDataAdapter("select * from table1", cn) ad1.Fill(ds, "table1") DataGridView1.DataSource = ds DataGridView1.DataMember = "table1" End Sub End Class