Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports MySql.Data.MySqlClient
- Public Class Form1
- Private Sub cmdsend_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsend.Click
- Dim conn As MySqlConnection
- 'connect to DB
- conn = New MySqlConnection()
- conn.ConnectionString = "server=mysql11.000webhost.com; user id=a3698183_reaper; password=GRalex1996; database=a3698183_siteme"
- '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 exits.
- If myData.HasRows = 0 Then
- MsgBox("Invalid Login!")
- Else
- MsgBox("Login Accepted!")
- Form2.Show()
- Me.Hide()
- End If
- End Sub
- End Class
Add Comment
Please, Sign In to add comment