Two SQL Passwords

gbargsley
10-26-2004, 06:02 PM
Hello all.

I am creating a little SQL utility that is going to run a quick query to update a field in a SQL database table if there is a date in it.

In our organization I found that there are two different passwords on our systems out in the field.

What my question is, how can I program the two passwords into my utility so that when it runs if it is not the first password, it will check the second one then run my update query.

If anyone can help with this I sure would appreciate it.

Thanks
Garry B

NEOLLE
10-26-2004, 06:29 PM
Hi Garry,
Ideally you can create a users profile table where both user passwords are in. You can create a function in VB or in PLSQL to verify if this passwords exits. Use this function whenever you do DML Commands. :)

gbargsley
10-26-2004, 06:32 PM
Can you post some sample code for what you are talking about?

NEOLLE
10-26-2004, 06:41 PM
Can you post some sample code for what you are talking about?

You can do modifications :)

Option Explicit

Private cn As ADODB.Connection

Private Sub DoUpdate(ByVal vPassword1 As String, ByVal vPassword2 As String)
With cn

If VerifyPassword(vPassword1, vPassword2) Then
'Do your DML here
'use the connections BeginTrans,CommitTrans and Execute methods
End If

End With
End Sub

Private Function VerifyPassword(ByVal vPassword1 As String, ByVal vPassword2 As String) As Boolean
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.Open _
"SELECT COUNT(*) AS RecordCount " & _
"FROM USERS " & _
"WHERE Password IN ('" & vPassword1 & "','" & vPassword2 & "')", cn, adOpenForwardOnly, adLockReadOnly
VerifyPassword = IIf(!RecordCount = 0, True, False)
.Close
End With
Set rs = Nothing
End Function

gbargsley
11-01-2004, 06:57 AM
Here is my code. How can I modify this code to look for two different passwords and then run my query? Helpppp....



Option Explicit
Public cnCOPOS As ADODB.Connection

Public Sub ConnectSQLDatabase()

Dim POSSQL_CONNECT As String
Dim sql As String
'Dim cnCOPOS As New adodb.Connection

'Establish settings
Set cnCOPOS = New ADODB.Connection
POSSQL_CONNECT = "Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=POSSQL;Data Source=127.0.0.1;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096; User ID=sa;password=hello"

'Connect the database
cnCOPOS.CursorLocation = adUseClient
cnCOPOS.Open POSSQL_CONNECT
cnCOPOS.CommandTimeout = 0

End Sub

Private Sub cmdRemoveAR_Click()

Dim rsSettings As ADODB.Recordset
Dim sql As String

Set rsSettings = New ADODB.Recordset
sql = "Update Settings SET MEMO = null Where (Setting = 'sARDates')"
rsSettings.Open sql, cnCOPOS, adOpenDynamic, adLockOptimistic

'rsSettings.Close
Set rsSettings = Nothing

Unload Me

End Sub

Private Sub Form_Load()

'Connect to database
Call ConnectSQLDatabase

End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum