daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest May 7th, 2016 25 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports MySql.Data.MySqlClient
  2.  
  3.  
  4. Public Class Form3
  5.  
  6.     Dim MySqlConn As MySqlConnection
  7.     Dim Command As MySqlCommand
  8.     Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  9.         Dim Username As String
  10.         Username = Form1.User
  11.         lblUser.Text = Username
  12.  
  13.         MySqlConn = New MySqlConnection
  14.         MySqlConn.ConnectionString = "server=localhost;userid=root;password=;database=StairwayToErrors"
  15.         Dim Reader As MySqlDataReader
  16.  
  17.         Try
  18.             MySqlConn.Open()
  19.             Dim Query As String
  20.             Query = "SELECT * FROM StairwaytoErrors.learner WHERE Username = '" & Username & "'"
  21.             Command = New MySqlCommand(Query, MySqlConn)
  22.             Reader = Command.ExecuteReader
  23.             While Reader.Read
  24.                 txtName.Text = Reader.GetString("Name")
  25.                 txtEmail.Text = Reader.GetString("Email")
  26.                 txtPhone.Text = Reader.GetString("Phone")
  27.                 txtAddress.Text = Reader.GetString("Address")
  28.                 dtpDateofBirth.Text = Reader.GetString("DateofBirth")
  29.  
  30.             End While
  31.             MySqlConn.Close()
  32.  
  33.         Catch ex As Exception
  34.             MessageBox.Show(ex.Message)
  35.         End Try
  36.  
  37.  
  38.  
  39.     End Sub
  40.  
  41.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  42.         MySqlConn = New MySqlConnection
  43.         MySqlConn.ConnectionString = "server=localhost;userid=root;password=;database=StairwayToErrors"
  44.         Dim Reader As MySqlDataReader
  45.  
  46.         Try
  47.             MySqlConn.Open()
  48.             Dim query As String
  49.             query = "UPDATE StairnwaytoErrors.Learner SET
  50.             (Name = '" & txtName.Text & "', Email = '" & txtEmail.Text & "', Phone = '" & txtPhone.Text & "', Address = '" & txtAddress.Text & "',
  51.             DateofBirth = '" & dtpDateofBirth.Text & "')"
  52.             Command = New MySqlCommand(query, MySqlConn)
  53.  
  54.             MessageBox.Show("Data Updated")
  55.             MySqlConn.Close()
  56.         Catch ex As Exception
  57.             MessageBox.Show(ex.Message)
  58.         End Try
  59.  
  60.  
  61.     End Sub
  62.  
  63.     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  64.         Me.Close()
  65.         Form1.Show()
  66.     End Sub
  67. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top