Hello all,
I am trying to make this login page for users, but when I go to login it gives me an Error or just does not work.
Here is what I am using.
Imports MySql.Data.MySqlClient
Public Class Form1
Public conn As MySqlConnection
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text & TextBox2.Text = "" = True Then MsgBox("Incorrect Information, please try again!", MsgBoxStyle.Information, "Login Error")
conn = New MySqlConnection("server=localhost; user id=example; password=example; database=example")
Try
conn.Open()
Dim sqlquery As String = "SELECT * FROM logins WHERE username = '" & TextBox1.Text & "';"
Dim data As MySqlDataReader
Dim adapter As New MySqlDataAdapter
Dim command As New MySqlCommand
command.CommandText = sqlquery
command.Connection = conn
adapter.SelectCommand = command
data = command.ExecuteReader
While data.Read()
If data.HasRows() = True Then
If data(2).ToString = TextBox2.Text Then
MsgBox("You have logged in " & TextBox1.Text, MsgBoxStyle.Information, "Logged in!")
Form3.Show()
Else
MsgBox("Incorrect information")
End If
End If
End While
Catch ex As Exception
MsgBox("Error!")
End Try
End Sub
End Class
If you see any errors could you please notify me? Thanks