So I have been trying to figure out why my login system hasn't been working. Is there a logical tutorial somewere online I can watch someone making one? or could you guys please help me figure this NOT on my line? :( I am sorry, First time working with SQL in Vb. Btw it is a distant hosted sql server.
Code:
Imports MySql.Data.MySqlClient
Imports System.Data.SqlClient
Public Class Form1
Dim conn As MySqlConnection
Private Sub ReconButton1_Click(sender As System.Object, e As System.EventArgs) Handles ReconButton1.Click
Dim conn As MySqlConnection
conn = New MySqlConnection()
conn.ConnectionString = "server=Host; user id=User; password=Pass; database=DB"
'see if connection failed
Try
conn.Open()
Catch myerror As MySqlException
MsgBox("Error connecting to server", MsgBoxStyle.Exclamation, "Error")
End Try
'sql query
Dim myAdapter As New MySqlDataAdapter
Dim sqlquery = "SELECT [] FROM users WHERE username = '" + TxtBox1.Text + "' AND password = '" + TxtBox2.Text + "'"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start query
myAdapter.SelectCommand = myCommand
`It highlights 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!")
Welcome.Show()
Me.Close()
End Sub