gumawa ako ng login form using vb.net with database para sa username at pas word.
program access and functions correctly, validates username and pass word thru ms access.
ang problem ko ay pg wala kang input sa username at password at press mo ung login button papasok pa rin cya.sana matulungan nio ako.
heres my code:
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim uname As String = ""
Dim pword As String = ""
Dim username As String = ""
Dim pass As String = ""
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("please fill all the info")
Else
uname = TextBox1.Text
pword = TextBox2.Text
Dim query As String = "select password from table1 where username='" & uname & "';"
Dim dbsource As String = "provider=microsoft.ace.oledb.12.0;data source=C:\Users\ASUS\Desktop\REPORTS\test.accdb"
Dim conn = New OleDbConnection(dbsource)
Dim cmd As New OleDbCommand(query, conn)
conn.Open()
Try
pass = cmd.ExecuteScalar().ToString
Catch ex As Exception
MsgBox("username does not exist")
End Try
End If
If (pword = pass) Then
MsgBox("login successful")
Form3.Show()
If Form3.Visible Then
Me.Hide()
End If
Else
MsgBox("login failed")
TextBox1.Clear()
TextBox2.Clear()
End If
End Sub
program access and functions correctly, validates username and pass word thru ms access.
ang problem ko ay pg wala kang input sa username at password at press mo ung login button papasok pa rin cya.sana matulungan nio ako.
heres my code:
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim uname As String = ""
Dim pword As String = ""
Dim username As String = ""
Dim pass As String = ""
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("please fill all the info")
Else
uname = TextBox1.Text
pword = TextBox2.Text
Dim query As String = "select password from table1 where username='" & uname & "';"
Dim dbsource As String = "provider=microsoft.ace.oledb.12.0;data source=C:\Users\ASUS\Desktop\REPORTS\test.accdb"
Dim conn = New OleDbConnection(dbsource)
Dim cmd As New OleDbCommand(query, conn)
conn.Open()
Try
pass = cmd.ExecuteScalar().ToString
Catch ex As Exception
MsgBox("username does not exist")
End Try
End If
If (pword = pass) Then
MsgBox("login successful")
Form3.Show()
If Form3.Visible Then
Me.Hide()
End If
Else
MsgBox("login failed")
TextBox1.Clear()
TextBox2.Clear()
End If
End Sub