Guest User

Untitled

a guest
Aug 19th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.27 KB | None | 0 0
  1. Imports MySql.Data.MySqlClient
  2.  
  3. Public Class Form1
  4.     Private Sub cmdsend_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsend.Click
  5.         Dim conn As MySqlConnection
  6.         'connect to DB
  7.         conn = New MySqlConnection()
  8.         conn.ConnectionString = "server=mysql11.000webhost.com; user id=a3698183_reaper; ­password=GRalex1996; database=a3698183_siteme"
  9.         'see if connection failed.
  10.         Try
  11.             conn.Open()
  12.         Catch myerror As MySqlException
  13.             MsgBox("Error connecting to database")
  14.         End Try
  15.         'sql query
  16.         Dim myAdapter As New MySqlDataAdapter
  17.  
  18.         Dim sqlquery = "SELECT * FROM login WHERE username = '" + txtuser.Text + "' AND password '" + txtpass.Text + "'"
  19.         Dim myCommand As New MySqlCommand()
  20.         myCommand.Connection = conn
  21.         myCommand.CommandText = sqlquery
  22.         'start query
  23.         myAdapter.SelectCommand = myCommand
  24.         Dim myData As MySqlDataReader
  25.         myData = myCommand.ExecuteReader()
  26.         'see if user exits.
  27.         If myData.HasRows = 0 Then
  28.             MsgBox("Invalid Login!")
  29.         Else
  30.             MsgBox("Login Accepted!")
  31.             Form2.Show()
  32.             Me.Hide()
  33.         End If
  34.     End Sub
  35. End Class
Add Comment
Please, Sign In to add comment