Imports MySql.Data.MySqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As MySqlConnection
'connect to DB
conn = New MySqlConnection()
conn.ConnectionString = "Server=localhost;User Id=root;Password=;Database=grapescorp"
'see if cennection failed
Try
conn.Open()
Catch myerror As MySqlException
MsgBox("ERROR CONNECTIng to database")
End Try
'
Dim myAdapter As New MySqlDataAdapter
Dim sqlquery = "SELECT * FROM data WHERE id='" + TextBox1.Text + "' AND name='" + TextBox2.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 exist
If myData.HasRows = 0 Then
MsgBox("Invalid Login")
Else
MsgBox("Login Accepted")
Form2.Show()
Me.Hide()
End If
Me.Close()
End Sub
End Class
how to download visual studio 2010 visual studio download 2010 2010 visual studio download visual studio 2010 download free free visual studio 2010 download download visual studio 2010 free
Thursday, June 9, 2011
Visual basic mysql login
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment