Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.OleDb
- Public Class Form1
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- End Sub
- Private Sub Src_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Src.Click
- Dim Connection1 As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:UsersSatyamDocumentsDatabase2.accdb;" & "Persist Security Info=False;" & "Jet OLEDB:Database Password=" & "your pass" & ";")
- Dim cmd As OleDbCommand
- Dim dr As OleDbDataReader
- Try
- Connection1.Open()
- cmd = New OleDbCommand("SELECT * from Table1 WHERE ID=" & IDtxt.Text & "", Connection1)
- dr = cmd.ExecuteReader
- If dr.Read Then
- Me.IDtxt.Text = dr("ID")
- Me.Hbtxt.Text = dr("Hb")
- Me.TCtxt.Text = dr("TC")
- Me.DCtxt.Text = dr("DC")
- dr.Close()
- Else
- MsgBox("No Record")
- End If
- Catch
- End Try
- Connection1.Close()
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim Connection1 As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:UsersSatyamDocumentsDatabase2.accdb;")
- Connection1.Open()
- Dim ID : ID = Me.IDtxt.Text
- Dim Hb : Hb = Me.Hbtxt.Text
- Dim TC : TC = Me.TCtxt.Text
- Dim DC : DC = Me.DCtxt.Text
- Dim command As New OleDbCommand("UPDATE Table1 SET Hb = '" & Hb & "',TC = '" & TC & "',DC = '" & DC & "' WHERE ID = '" & ID & "'", Connection1)
- Command.ExecuteNonQuery()
- Connection1.Close()
- End Sub
- Dim command As New OleDbCommand("UPDATE Table1 SET Hb = @hb,TC = @tc,DC = @DC WHERE ID = @id", Connection1)
- Command.parameters.add(new sqlparameter("@hb",Hb))
- Command.parameters.add(new sqlparameter("@tc",tc))
- Command.parameters.add(new sqlparameter("@dc",dc))
- Command.parameters.add(new sqlparameter("@id",id))
- Command.ExecuteNonQuery()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement