SHARE
TWEET

Untitled

a guest May 7th, 2016 122 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports MySql.Data.MySqlClient
  2.  
  3. Public Class Form1
  4.     Public User As String
  5.  
  6.     Dim MySqlConn As MySqlConnection
  7.     Dim Command As MySqlCommand
  8.  
  9.     Public Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  10.         User = txtUsername.Text
  11.  
  12.         Dim Reader As MySqlDataReader
  13.  
  14.         MySqlConn = New MySqlConnection
  15.         MySqlConn.ConnectionString = "server=localhost;userid=root;password=;database=StairwayToErrors"
  16.  
  17.         Try
  18.             MySqlConn.Open()
  19.             Dim Query As String
  20.             Query = "SELECT * FROM StairwayToErrors.Learner WHERE Username = '" & txtUsername.Text & "' AND Password = '" & txtPassword.Text & "'"
  21.             Command = New MySqlCommand(Query, MySqlConn)
  22.             Reader = Command.ExecuteReader
  23.  
  24.             If cmbRole.Text = "Learner" And Reader.HasRows Then
  25.                 Form3.Show()
  26.                 Me.Hide()
  27.             ElseIf cmbRole.Text = "Admin" And txtUsername.Text = "admin" And txtPassword.Text = "123" Then
  28.                 Form3.Show()
  29.                 Me.Hide()
  30.             Else
  31.                 MessageBox.Show("Feil")
  32.             End If
  33.  
  34.             MySqlConn.Close()
  35.         Catch ex As Exception
  36.             MessageBox.Show(ex.Message)
  37.         Finally
  38.             MySqlConn.Dispose()
  39.         End Try
  40.  
  41.     End Sub
  42.  
  43.     Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  44.         Me.Close()
  45.     End Sub
  46.  
  47.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  48.         Form2.Show()
  49.         Me.Hide()
  50.     End Sub
  51. 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