Imports System.Data.
OleDb
Public Class login01
Dim cmd As OleDbCommand
Dim que As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("fields are empty")
Exit Sub
End If
Dim conn As New OleDbConnection(My.Settings.nvydbConnectionString)
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
que = "select * from login_table where login=@login and pass=@pass"
cmd = New OleDbCommand(que, conn)
cmd.Parameters.AddWithValue("@login", TextBox1.Text)
cmd.Parameters.AddWithValue("@pass", TextBox2.Text)
Dim result As Integer = Convert.ToInt32(cmd.ExecuteScalar)
If result > 0 Then
MsgBox("logged in")
HOMEP.Show()
Me.Hide()
Else
MsgBox("invalid username and password")
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("fields are empty")
Exit Sub
End If
Dim conn As New OleDbConnection(My.Settings.nvydbConnectionString)
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
que = "insert into login_table(login,pass)values(@login,@pass)"
cmd = New OleDbCommand(que, conn)
cmd.Parameters.AddWithValue("@login", TextBox1.Text)
cmd.Parameters.AddWithValue("@pass", TextBox2.Text)
If cmd.ExecuteNonQuery Then
MsgBox("signed up successfully")
TextBox1.clear()
TextBox2.clear()
End If
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles
TextBox2.TextChanged
End Sub
Private Sub login01_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class