Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

guys pa help nmn...

swit4n93l

Recruit
Basic Member
Messages
16
Reaction score
0
Points
16
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
 
Check revised script sequence

If TextBox1.Text = "" or TextBox2.Text = "" Then
MsgBox("please fill all the info")
Else

'Dim query As String = "select password from table1 where username='" & uname & "';"

'Change to

Dim query As String = "select top 1 * from table1 where username='" & uname & "' and pass='" & pword & "';"

'kapag may ni-return na contents, ibig sabihin, may match yung supplied username and password

'if query returned a matching row, do this
MsgBox("login successful")
Form3.Show()
Me.Hide()
'else
MsgBox("login failed")
TextBox1.Clear()
TextBox2.Clear()
'end if

End if
 
boss ganun pa rin eh.pag d mo nilagyan ung username at password at press mo ung login button lalabas lng ung msgbox den ipapakita pa rin nya ung form3
 
Ginawa mo ba yung nasa instruction?

Ilagay mo yung form show AFTER mo i-check kung meron nakitang match for the supplied username & password.

Also, I highlighted the ELSE portion kung saan mo isisingit yung query pati na din yung resulting row, pati na nga din ung form show script

If TextBox1.Text = "" or TextBox2.Text = "" Then
MsgBox("please fill all the info")
Else

'Dim query As String = "select password from table1 where username='" & uname & "';"

'Change to

Dim query As String = "select top 1 * from table1 where username='" & uname & "' and pass='" & pword & "';"

'kapag may ni-return na contents, ibig sabihin, may match yung supplied username and password

'if query returned a matching row, do this
MsgBox("login successful")
Form3.Show()
Me.Hide()
'else
MsgBox("login failed")
TextBox1.Clear()
TextBox2.Clear()
'end if

End if
 
thnxs boss.try ko ulit, ausin ko code. nalilito tlga ako ahaha.working nmn cya un nga lng pag wla ka ininput sa username at pass lalabas pa rin ung for 3 pg pinalitan ko nmn ung query nag eeror na d na nya magawang i access young database.if d nmn kalabisan pa paste nmn ung working syntax.thnxs in advance.newbie pa lng ako kc sa vb.net
 
Back
Top Bottom