Hi guys i am a total beginner on VB.As mention on the tittle i would love a help on my problem.Here is my code
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Public Class Form1
Dim conn As New System.Data.OleDb.OleDbConnection()
Private Sub btnSignUp_Click(sender As Object, e As EventArgs) Handles btnSignUp.Click
Me.Hide()
Form2.Show()
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnSignIn_Click(sender As Object, e As EventArgs) Handles btnSignIn.Click
Dim sql As String = "SELECT * FROM table WHERE Username='" & UsernameTextBox.Text & "' AND Password = '" & PassTextBox.Text & "'"
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql)
Dim sqlRead As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
If sqlRead.Read() Then
Form3.Show()
Me.Hide()
Else
' If user enter wrong username and password combination
' Throw an error message
MessageBox.Show("Username and Password do not match..", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
'Clear all fields
PassTextBox.Text = ""
UsernameTextBox.Text = ""
'Focus on Username field
UsernameTextBox.Focus()
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\ser\Desktop\test.accdb"
If conn.State = ConnectionState.Closed Then
MsgBox("OPEN")
Else
MsgBox("CLOSE")
End If
End Sub
End Class