VERSIONS: All
SUBJECT: Login to a database that requires a password
BY: BERTIL ISBERG
Date: 30 June 1997
Background:
Your application has a customized Login form, and you want to store the password used when logging in to a database.
You retrieve the password from your login form and apply it with setAliasPassword(). When you do, a database.open() will by default bring
up the Paradox builtin password screen if the userid or password provided is incorrect. There is no way to catch that the open failed, because it
doesn't if the user provides the correct password to the builtin dialog. So now you are in a situation where your application does not know the
password used.
But, if you instead use the database.open() syntax where the alias settings are provided as a dynarray of strings
open ( [ const aliasName String, ] [ const ses Session, ]
[ const parms DynArray ] ) Logical
the builtin password dialog will not show up if incorrect. Write the database.open() inside a try statement, and onFail will execute if the
password was incorrect. Now your code has control over the password assignment and the evaluation of it.
var
darstParams DynArray[] string
/*
stUser, stPassword string declared outside this method
dbHandle database declared outside this method
*/
endVar
message("Accessing remote database...")
; darstParams["Database"] = "dbname"
while TRUE
; Code to get user name and password from the user
;
darstParams["User name"] = stUser
darstParams["Password"] = stPassword
try
dbHandle.open(":remdata:",darstParams)
message("Database opened.")
quitloop
onFail
errorclear()
message("Could not login to the database. Incorrect information provided.")
endtry
endWhile
endMethod