Two SQL Passwords

10-26-2004, 05: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.

Garry B

10-26-2004, 05: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. :)

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

10-26-2004, 05: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 " & _
"WHERE Password IN ('" & vPassword1 & "','" & vPassword2 & "')", cn, adOpenForwardOnly, adLockReadOnly
VerifyPassword = IIf(!RecordCount = 0, True, False)
End With
Set rs = Nothing
End Function

11-01-2004, 05: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 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=;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096; User ID=sa;password=hello"

'Connect the database
cnCOPOS.CursorLocation = adUseClient
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

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