|
-
Aug 16th, 2001, 03:57 AM
#1
Thread Starter
Member
Password and Login
Hi Guys, does anyone have an example of some VB code and SQL where when a user is trying to LOGIN with his password and username, it compaires it in the database and then allows them to be logged in, if you know what i mean.
SQL = "UPDATE register " _
& " SET password = " & sPassword _
& " , username = " & sUsername _
& " WHERE MessageIndex = " & iIndex
would this be correct or not as it seems wrong to me.
Charlie
Last edited by charliemancini; Aug 16th, 2001 at 04:44 AM.
-
Aug 16th, 2001, 07:51 AM
#2
Fanatic Member
If you are using access you could try something like:
VB Code:
SQL = "Select 1 " & _
"From register " & _
"Where username='" & sUsername & "' " & _
"And password = '" & sPassword & "'"
'ConnObject is you connection to the database
rs.open SQL, ConnObject, adOpenStatic, adLockReadOnly
'If no records returned then the login failed
If rs.recordcount = 0 then
MsgBox "Login Attemp Failed."
Exit Sub
'Login was successfull
Else
'Continue w/ processing
End If
If you are using SQL Server, create a connection string to the database you are trying to connect to and perform some error trapping to make sure the user is a valid user:
VB Code:
Dim conn as Connection
Dim ConnStr as String
ConnStr = "Provider=SQLOLEDB;Server=YourServer;"
ConnStr = ConnStr & "Database=YourDatabase;UID=" & sUserName
ConnStr = ConnStr & ";PWD=" & sPassword
set conn = new connection
On Error Goto ErrHandler
Conn.Open connStr
Exit Sub
ErrHandler:
If Err = -2147217843 Then
msgbox "Verify UserName and Password"
exit sub
End If
Hope this helps.
Chris
Chris
Master Of My Domain
Got A Question? Look Here First
-
Aug 16th, 2001, 08:10 AM
#3
Thread Starter
Member
I'm sure it will, thanks Chris
p.s. i'm doing it in VB and Access
Charlie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|