Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. Imports System.Data.OleDb
  2. Public Class Form1
  3.  
  4. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  5.  
  6. End Sub
  7.  
  8. Private Sub Src_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Src.Click
  9. 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" & ";")
  10. Dim cmd As OleDbCommand
  11.  
  12. Dim dr As OleDbDataReader
  13. Try
  14. Connection1.Open()
  15. cmd = New OleDbCommand("SELECT * from Table1 WHERE ID=" & IDtxt.Text & "", Connection1)
  16.  
  17. dr = cmd.ExecuteReader
  18. If dr.Read Then
  19. Me.IDtxt.Text = dr("ID")
  20. Me.Hbtxt.Text = dr("Hb")
  21. Me.TCtxt.Text = dr("TC")
  22. Me.DCtxt.Text = dr("DC")
  23.  
  24. dr.Close()
  25. Else
  26. MsgBox("No Record")
  27. End If
  28. Catch
  29. End Try
  30. Connection1.Close()
  31. End Sub
  32.  
  33.  
  34. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  35. Dim Connection1 As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:UsersSatyamDocumentsDatabase2.accdb;")
  36. Connection1.Open()
  37. Dim ID : ID = Me.IDtxt.Text
  38. Dim Hb : Hb = Me.Hbtxt.Text
  39. Dim TC : TC = Me.TCtxt.Text
  40. Dim DC : DC = Me.DCtxt.Text
  41.  
  42.  
  43. Dim command As New OleDbCommand("UPDATE Table1 SET Hb = '" & Hb & "',TC = '" & TC & "',DC = '" & DC & "' WHERE ID = '" & ID & "'", Connection1)
  44. Command.ExecuteNonQuery()
  45.  
  46. Connection1.Close()
  47.  
  48.  
  49. End Sub
  50.  
  51. Dim command As New OleDbCommand("UPDATE Table1 SET Hb = @hb,TC = @tc,DC = @DC WHERE ID = @id", Connection1)
  52.  
  53. Command.parameters.add(new sqlparameter("@hb",Hb))
  54. Command.parameters.add(new sqlparameter("@tc",tc))
  55. Command.parameters.add(new sqlparameter("@dc",dc))
  56. Command.parameters.add(new sqlparameter("@id",id))
  57. Command.ExecuteNonQuery()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement