Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub button4_Click(sender As Object, e As EventArgs) Handles button4.Click 'When the login button is clicked the data inside of the username and password textbox is checked against the database
- Dim cs As String = "server=95.128.129.130; user id=dsfcuser5; password=!ANeusdj2DVCb!; database=dbdsfc5;" 'Server details, username and password
- Dim conn As New MySqlConnection(cs)
- Try
- conn.Open() 'Opens the mysql connection that is declared above
- Dim stm As String = "SELECT * FROM dbdsfc5.accounts WHERE username='" & username.Text + "' AND password='" & encryption.hashString(password.Text) & "' " 'sql command is declared as stm variable
- Dim cmd As MySqlCommand = New MySqlCommand(stm, conn)
- Dim reader As MySqlDataReader = cmd.ExecuteReader()
- Dim count As Integer = 0
- While reader.Read() 'while the reader is pulling data
- count = count + 1 'increment the count
- End While
- If count = 1 Then 'if the count is one it has sucessfully pulled corrosponding data from the database
- MessageBox.Show("Sucess") 'display sucess
- userID = reader.GetString(0)
- panel2.Hide() 'Hide the login form if the login is correct
- panel1.Show() 'Show the main UI if the login is correct
- FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle 'Becomes a sizeable window
- Me.ShowIcon = True
- Me.Width = 754 'change the size of the form so that
- Me.Height = 583
- Me.MaximumSize = New Size(677, 525)
- Me.MinimumSize = New Size(677, 525)
- 'Form2 location and show
- Dim frm1Width As Integer = Me.Width
- If Form2.Visible = False Then
- Form2.Show()
- 'set form2's new location beside form1 by adding frm1's width to its current X Position and just use the frm1's Y Position to level both forms
- Form2.Location = New Point(Me.Location.X + frm1Width, Me.Location.Y)
- Else
- Form2.Hide()
- End If
- getSug() 'gets sugars from the data table in the database
- Stats() 'calculates stats from the requested data
- ElseIf count > 1 Then
- MessageBox.Show("Duplicate users") 'if there is already an entry
- Else
- MessageBox.Show("Incorrect login: querey failed")
- End If
- reader.Close() 'close the reader which requested the data for the login
- Catch ex As MySqlException
- Console.WriteLine("Error: " & ex.ToString())
- Finally
- conn.Close()
- End Try
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement