borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Urgent Help)Next Topic (VB and Excel) New Topic New Poll Post Reply
AndreaVB Forum : Database : User Login/Password Checking
Poster Message
rdingus
Level: Guest


Ads by Lake Quincy Media
icon User Login/Password Checking

I need help coding a user login to control access to a data collection application using a laser scanner. I am storing the user name and password in an access 2000 database. And using adodc1 with an odbc link to the data from the application, to get around the access 97 problem with VB 6.0. IE. vb 6 cannot directly access a 2000 database without converting to a prior version.

I want the user name and password, verified from the login form against user and login in the database. Any help would be great. Thanks rdingus

26-01-2003 at 12:49 AM
| Quote Reply
MohamedAnwar
Level: Guest

icon Re: User Login/Password Checking


HI
You could use Microsoft Jet 4.0 OLE DB provider that would connect to office 2000 with a password

Ads by Lake Quincy Media
04-03-2003 at 11:03 AM
| Quote Reply
rdingus
Level: Guest

icon Re: User Login/Password Checking

Thank you for the reply, this is how i got it to work.


Option Explicit
Public LoginSucceeded As Boolean
Public Operatorname As String

Private Sub CancelButton_Click()

LoginSucceeded = False
Me.Hide
End
End Sub

Private Sub Form_Load()

End Sub

Private Sub OKButton_Click()
Dim Operator As String
Dim UserPassword As String
Dim sSQL As String
Dim LoginSuceeded As Boolean


sSQL = "Select * From Operators Where Operator = '" & txtOperator.Text & "'"
Adodc1.RecordSource = sSQL
Adodc1.Refresh


If Adodc1.Recordset.RecordCount < 1 Then
    MsgBox "Invalid User Name or Password, Try Again.", , "Login"
          txtPassword.Text = ""
        txtOperator.Text = ""
        txtOperator.SetFocus
        SendKeys "{Home}+{End}"
         LoginSuceeded = False

Else
    Adodc1.Recordset.MoveFirst
    If Adodc1.Recordset.Fields(1).Value = txtPassword.Text Then
        LoginSuceeded = True
        
    Else
        MsgBox "Invalid User Name or Password, Try Again!", , "Login"
              txtPassword.Text = ""
        txtOperator.Text = ""
        txtOperator.SetFocus
        SendKeys "{Home}+{End}"
        LoginSuceeded = False
    End If
    

        If LoginSuceeded = True Then
            Me.Hide
        
            frmSwitchboard.Show 'Show the switchBoard form next
        OpName = txtOperator.Text
          
        End If
    
    End If


End Sub


05-03-2003 at 01:22 AM
| Quote Reply
Shady
Level: VB Guru


Registered: 08-07-2002
Posts: 305
icon Re: User Login/Password Checking

Hi there,

Having seen you are using passwords and logins, I thought this may be of interest.  I use this in one of my programs, it stops anyone openeing your access Dbase and reading the passwords.

It uses a simple but effective encryption algorythm.



'Encrypt - Rudimentary encryption/decryption demo program
'Copyright (c) 1997 SoftCircuits Programming (R)
'Redistributed by Permission.
'
'This program may be distributed on the condition that it is
'distributed in full and unchanged, and that no fee is charged for
'such distribution with the exception of reasonable shipping and media
'charged. In addition, the code in this program may be incorporated
'into your own programs and the resulting programs may be distributed
'without payment of royalties.
'
'This example program was provided by:
' SoftCircuits Programming
' http://www.softcircuits.com
' P.O. Box 16262
' Irvine, CA 92623
Option Explicit

'Set to True to make the password case-sensitive
#Const CASE_SENSITIVE_PASSWORD = False

Private Sub cmdEncrypt_Click()
    txtText = EncryptText((txtText), txtPassword)
End Sub

Private Sub cmdDecrypt_Click()
    txtText = DecryptText((txtText), txtPassword)
End Sub

'Encrypt text
Private Function EncryptText(strText As String, ByVal strPwd As String)
    Dim i As Integer, c As Integer
    Dim strBuff As String

#If Not CASE_SENSITIVE_PASSWORD Then

    'Convert password to upper case
    'if not case-sensitive
    strPwd = UCase$(strPwd)

#End If

    'Encrypt string
    If Len(strPwd) Then
        For i = 1 To Len(strText)
            c = Asc(Mid$(strText, i, 1))
            c = c + Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
            strBuff = strBuff & Chr$(c And &HFF)
        Next i
    Else
        strBuff = strText
    End If
    EncryptText = strBuff
End Function

'Decrypt text encrypted with EncryptText
Private Function DecryptText(strText As String, ByVal strPwd As String)
    Dim i As Integer, c As Integer
    Dim strBuff As String

#If Not CASE_SENSITIVE_PASSWORD Then

    'Convert password to upper case
    'if not case-sensitive
    strPwd = UCase$(strPwd)

#End If

    'Decrypt string
    If Len(strPwd) Then
        For i = 1 To Len(strText)
            c = Asc(Mid$(strText, i, 1))
            c = c - Asc(Mid$(strPwd, (i Mod Len(strPwd)) + 1, 1))
            strBuff = strBuff & Chr$(c And &HFF)
        Next i
    Else
        strBuff = strText
    End If
    DecryptText = strBuff
End Function



All you need on your form are:-

Textboxes - txtText & txtPassword
Buttons - cmdEncrypt & cmdDecrypt

Hope this is of use

Regards

Shady

____________________________
I don't wanna die... but I ain't keen on livin' either

05-03-2003 at 10:27 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : User Login/Password Checking
Previous Topic (Urgent Help)Next Topic (VB and Excel) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder