33 Replies - 54832 Views - Last Post: 24 August 2010 - 08:10 AM
#16
Re: login code - Visual Basic 6.0
Posted 12 October 2007 - 07:29 AM
#17
Re: login code - Visual Basic 6.0
Posted 12 October 2007 - 07:43 AM
#18
Re: login code - Visual Basic 6.0
Posted 12 October 2007 - 07:54 AM
#19
Re: login code - Visual Basic 6.0
Posted 12 October 2007 - 08:09 AM
For find to work, you'll have to bind a control to your ADODC. So create a textbox and bind it. Now the following code should work easily. Im surely you'll be able to understand what's happening
Adodc1.Recordset.Find "UserName ='" + txtUserName.Text + "'", 0, adSearchForward, adBookmarkFirst
If (Adodc1.Recordset.EOF = False) Then
If (txtPassword.Text = Adodc1.Recordset.Fields("Password")) Then
MsgBox ("Login Successful")
Else
MsgBox ("Login Failure. Incorrect Password")
End If
Else
MsgBox ("Login Failure. Username does not exist.")
End If
Don't ask me why you need to bind a control. I don't know.
#20
Re: login code - Visual Basic 6.0
Posted 12 October 2007 - 08:44 PM
#21
Re: login code - Visual Basic 6.0
Posted 12 October 2007 - 08:49 PM
antukin_cs, on 12 Oct, 2007 - 08:44 PM, said:
The language that interacts with SQL is the same language that interacts with Access, Transact-SQL is simply the programming language that interacts with those 2 database types.
The database code you are viewing from Louisda16th is Transact-SQL, you can take that query and run it in either Microsoft SQL Server or Microsoft Access.
#22
Re: login code - Visual Basic 6.0
Posted 12 October 2007 - 08:56 PM
Private Sub cmdOK_Click() static y as integer adodc1.refresh with adodc1.recordset if .recordset > 0 then .movefirst .find "Username'="&txtUsername&"'" .find "Password='"&txtPassword&"'" if .EOF=false then if !Username=txtUsername and !Password=txtPassword then unload me msgbox"Access granted!" end if end sub
anybody please help me!
PsychoCoder, on 12 Oct, 2007 - 08:49 PM, said:
antukin_cs, on 12 Oct, 2007 - 08:44 PM, said:
The language that interacts with SQL is the same language that interacts with Access, Transact-SQL is simply the programming language that interacts with those 2 database types.
The database code you are viewing from Louisda16th is Transact-SQL, you can take that query and run it in either Microsoft SQL Server or Microsoft Access.
well i cant use that code.. i posted the code our instructor gave us..maybe you can fix it...
This post has been edited by antukin_cs: 12 October 2007 - 08:54 PM
#23
Re: login code - Visual Basic 6.0
Posted 12 October 2007 - 09:20 PM
#24
Re: login code - Visual Basic 6.0
Posted 12 October 2007 - 09:31 PM
.find "Password='"&txtPassword&"'"
these codes were highlighted after typing them....
#25
Re: login code - Visual Basic 6.0
Posted 13 October 2007 - 12:08 AM
And DONOT direct your posts towards a particular member. You'll get lesser replies. There are people here a billion times better than me in VB.
#26
Re: login code - Visual Basic 6.0
Posted 13 October 2007 - 08:17 PM
Bro, change the code
.find "Username'="&txtUsername&"'"
.find "Password='"&txtPassword&"'"
with this one
.find "Username = '" & trim(txtUsername) &"'"
.find "Password = '" & trim(txtPassword) &"'"
Note: I add trim to remove the trailing space/s.
Hope this help.
Project ba bro?
#27
Re: login code - Visual Basic 6.0
Posted 14 October 2007 - 10:26 PM
russell214, on 13 Oct, 2007 - 08:17 PM, said:
Bro, change the code
.find "Username'="&txtUsername&"'"
.find "Password='"&txtPassword&"'"
with this one
.find "Username = '" & trim(txtUsername) &"'"
.find "Password = '" & trim(txtPassword) &"'"
Note: I add trim to remove the trailing space/s.
Hope this help.
Project ba bro?
yeah, enrollment system... where wud i replace these code?? to d original dat i gave out??
#28
Re: login code - Visual Basic 6.0
Posted 14 October 2007 - 10:56 PM
antukin_cs, on 14 Oct, 2007 - 10:26 PM, said:
russell214, on 13 Oct, 2007 - 08:17 PM, said:
Bro, change the code
.find "Username'="&txtUsername&"'"
.find "Password='"&txtPassword&"'"
with this one
.find "Username = '" & trim(txtUsername) &"'"
.find "Password = '" & trim(txtPassword) &"'"
Note: I add trim to remove the trailing space/s.
Hope this help.
Project ba bro?
yeah, enrollment system... where wud i replace these code?? to d original dat i gave out??
Here is yout original code
Private Sub cmdOK_Click()
static y as integer
adodc1.refresh
with adodc1.recordset
if .recordset > 0 then
.movefirst
.find "Username'="&txtUsername&"'" ' this is the error replace with ***
.find "Password='"&txtPassword&"'" '
if .EOF=false then
if !Username=txtUsername and !Password=txtPassword then
unload me
msgbox"Access granted!"
end if
end sub
----
***
.find "Username = '" & trim(txtUsername) &"'"
.find "Password = '" & trim(txtPassword) &"'"
#29
Re: login code - Visual Basic 6.0
Posted 14 October 2007 - 11:02 PM
Adodc1.Recordset.Find "UserName ='" + txtUserName.Text + "'", 0, adSearchForward, adBookmarkFirst
The last argument, adBookMarkFirst takes care of it. See Post #19 again. I haven't used SQL at all. I think it should serve your purpose. Just remember to create an extra textbox/label and bind it to your ADO data control.
Hope this helps
#30
Re: login code - Visual Basic 6.0
Posted 14 October 2007 - 11:09 PM
Quote
.find "Password = '" & trim(txtPassword) &"'"
A small problem with this. Your code will first check for a record with the username matching. Next it will check for a record with the password matching. You won't quite achieve anything with this. Let me explain. Suppose you have a table like this:
UserName PassWord Scott tiger Andrew cheetah Peter lion
Suppose you enter Andrew for username and tiger for password, at the end of the two find statements, you'll end up at record 1. Now that's not the record Andrew was looking at. It'll return an incorrect username instead of password. I hope Im making sense
Hope this helps
This post has been edited by Louisda16th: 14 October 2007 - 11:11 PM
|
|

New Topic/Question
Reply





MultiQuote


|