Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim conn As MySqlConnection
- 'connect to DB
- conn = New MysqlConnection()
- conn.ConnectionString = "server=yourwebsitehere.com; user id=your_username_here; password=your_password_here; database=yourdatabase_namehere"
- 'see if connection failed.
- Try
- conn.Open()
- Catch myerror As MySqlException
- MsgBox("Error connecting to database!")
- End Try
- 'sql query
- Dim myAdapter As New MySqlDataAdapter
- Dim sqlquery = "SELECT * FROM login WHERE username='" + txtuser.Text + "' AND password= '" + txtpass.Text + "'"
- Dim myCommand As New MySqlCommand()
- myCommand.Connection = conn
- myCommand.CommandText = sqlquery
- 'start query
- myAdapter.SelectCommand = myCommand
- Dim myData As MySqlDataReader
- myData = myCommand.ExecuteReader()
- 'see if user exists
- If myData.HasRows = 0 Then
- MsgBox("Invalid username and/or password!")
- Else
- MsgBox("Login Accepted!")
- Form1.Show()
- Me.Hide()
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement