0% found this document useful (0 votes)
11 views2 pages

Suraj

The document is a Visual Basic code for a login form that allows users to log in or sign up. It checks if the input fields are empty, connects to a database, and validates user credentials against a login table. If the login is successful, it shows a home form; otherwise, it displays an error message.

Uploaded by

Frustrated World
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Suraj

The document is a Visual Basic code for a login form that allows users to log in or sign up. It checks if the input fields are empty, connects to a database, and validates user credentials against a login table. If the login is successful, it shows a home form; otherwise, it displays an error message.

Uploaded by

Frustrated World
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

You might also like