Hi,
I am using VB6 and SQL Server 2000.
I want to design a logon form. In this form, how can I use a Password field to store in encrypted form in tbluser table and how can I compare password text in this table?
Please tell me how I can use encode/decoder algorithm to secure password.
User form coding is as follows :-
[CODE=vb]Dim sql As String
Dim adcon As ADODB.Connectio n
Dim rs As ADODB.Recordset
Dim sqldata As String
Private Sub Form_Load()
'get a connection
cmd = "Provider=sqlol edb;" & "Data Source=xyz;" & "Initial Catalog=edp07;" & "User Id=sa;"
Set adcon = New ADODB.Connectio n
adcon.Open cmd
sqldata = "select * from tbluser"
'Set new ADO recordset object
Set rs = New ADODB.Recordset
rs.Open sqldata, adcon, adOpenStatic, adLockOptimisti c
End Sub
Private Sub cmdAdd_Click()
'Coding to clear the text box
txtId.Text = ""
txtUser.Text = ""
txtPassword.Tex t = ""
'txtDId.SetFocu s
rs.AddNew
End Sub
Private Sub cmdSave_Click()
rs(0) = txtId.Text
rs(1) = txtUser.Text
'**** I Want to save this field in encrypted form in SQL Server 2000 in table tbluser ! pls help me ****
rs(2) = txtPassword.Tex t
rs.Update
MsgBox "Entry Saved"
rs.Requery
End Sub[/CODE]
Login form coding is as follows :-
[CODE=vb]Option Explicit
Dim adcon As ADODB.Connectio n
Dim rs As ADODB.Recordset
Dim sqldata As String
Dim cmd As String
Public LoginSucceeded As Boolean
Private Sub Form_Load()
'get a connection
cmd = "Provider=sqlol edb;" & "Data Source=xyz;" & "Initial Catalog=edp07;" & "User Id=sa;"
Set adcon = New ADODB.Connectio n
adcon.Open cmd
sqldata = "select * from tbluser"
'Set new ADO recordset object
Set rs = New ADODB.Recordset
rs.Open sqldata, adcon, adOpenStatic, adLockOptimisti c
End Sub
Private Sub cmdOK_Click()
'check for correct password
If rs.RecordCount = 0 Then
MsgBox ("No recordset")
Exit Sub
End If
'check for correct username and password
rs.MoveFirst
Do While Not rs.EOF
If txtUserName = RTrim(rs.Fields ("name")) Then
'**** I Want to compare encrypted data in SQL Server 2000 in table tbl user! Please help me ****
If txtPassword = RTrim(rs.Fields ("Password") ) Then
LoginSucceeded = True
Me.Hide
Form1.Show
End If
End If
rs.MoveNext
Loop
If Not LoginSucceeded Then
MsgBox "Invalid UserName/Password, try again!", , "Login"
txtPassword.Set Focus
SendKeys "{Home}+{En d}"
End If
End Sub[/CODE]
Can anyone help?
Thanks.
pawan
I am using VB6 and SQL Server 2000.
I want to design a logon form. In this form, how can I use a Password field to store in encrypted form in tbluser table and how can I compare password text in this table?
Please tell me how I can use encode/decoder algorithm to secure password.
User form coding is as follows :-
[CODE=vb]Dim sql As String
Dim adcon As ADODB.Connectio n
Dim rs As ADODB.Recordset
Dim sqldata As String
Private Sub Form_Load()
'get a connection
cmd = "Provider=sqlol edb;" & "Data Source=xyz;" & "Initial Catalog=edp07;" & "User Id=sa;"
Set adcon = New ADODB.Connectio n
adcon.Open cmd
sqldata = "select * from tbluser"
'Set new ADO recordset object
Set rs = New ADODB.Recordset
rs.Open sqldata, adcon, adOpenStatic, adLockOptimisti c
End Sub
Private Sub cmdAdd_Click()
'Coding to clear the text box
txtId.Text = ""
txtUser.Text = ""
txtPassword.Tex t = ""
'txtDId.SetFocu s
rs.AddNew
End Sub
Private Sub cmdSave_Click()
rs(0) = txtId.Text
rs(1) = txtUser.Text
'**** I Want to save this field in encrypted form in SQL Server 2000 in table tbluser ! pls help me ****
rs(2) = txtPassword.Tex t
rs.Update
MsgBox "Entry Saved"
rs.Requery
End Sub[/CODE]
Login form coding is as follows :-
[CODE=vb]Option Explicit
Dim adcon As ADODB.Connectio n
Dim rs As ADODB.Recordset
Dim sqldata As String
Dim cmd As String
Public LoginSucceeded As Boolean
Private Sub Form_Load()
'get a connection
cmd = "Provider=sqlol edb;" & "Data Source=xyz;" & "Initial Catalog=edp07;" & "User Id=sa;"
Set adcon = New ADODB.Connectio n
adcon.Open cmd
sqldata = "select * from tbluser"
'Set new ADO recordset object
Set rs = New ADODB.Recordset
rs.Open sqldata, adcon, adOpenStatic, adLockOptimisti c
End Sub
Private Sub cmdOK_Click()
'check for correct password
If rs.RecordCount = 0 Then
MsgBox ("No recordset")
Exit Sub
End If
'check for correct username and password
rs.MoveFirst
Do While Not rs.EOF
If txtUserName = RTrim(rs.Fields ("name")) Then
'**** I Want to compare encrypted data in SQL Server 2000 in table tbl user! Please help me ****
If txtPassword = RTrim(rs.Fields ("Password") ) Then
LoginSucceeded = True
Me.Hide
Form1.Show
End If
End If
rs.MoveNext
Loop
If Not LoginSucceeded Then
MsgBox "Invalid UserName/Password, try again!", , "Login"
txtPassword.Set Focus
SendKeys "{Home}+{En d}"
End If
End Sub[/CODE]
Can anyone help?
Thanks.
pawan
Comment