Here is a sample you can compile and use. Change the database (yourdatabase)
to the one you need to connect to and ownersname ('OWNERSNAME') within the file
$COMMAND
conn2db
SET VAR vg_db = NULL
--Use the error variable to capture the error, but don't use it
--to test with for a connection failure. Set another var to it
--so it can be tested against. Testing against errvar can cause
--RBase to crash.
SET VAR %1-1 TEXT
SET VAR %2-1 TEXT
SET VAR %3-1 TEXT
IF %1-1 = NULL THEN
SET VAR %1-1 TEXT = 'NONAME'
ENDIF
IF %2-1 = NULL THEN
SET VAR %2-1 TEXT = 'NONAME'
ENDIF
IF %3-1 = NULL THEN
SET VAR %3-1 TEXT = 'NONAME'
ENDIF
SET ERROR VARIABLE errvar
SET VAR vm_interr INTEGER
SET VAR vm_user TEXT = 'NONAME'
SET VAR vm_user = (CVAL('NAME'))
--USE netuser to get devices windows login name
--SET VAR vm_user = (CVAL('NETUSER'))
SET VAR vm_user = (STRIM(.vm_user))
SET VAR vm_user = (LUC(.vm_user))
IF vm_user = .%1-1 OR vm_user = .%2-1 OR vm_user = .%3-1 THEN
SET VAR vm_user = 'OWNERSNAME'
CONNECT yourdatabase IDENTIFIED BY &vm_user
SET VAR vm_interr = .errvar
IF vm_interr <> 0 THEN
PAUSE +
FOR 2 USING 'ERROR: Could not connect to database' +
CAPTION 'Connection error' AT CENTER CENTER
CLEAR VAR vm_user, vm_interr
CLEAR VAR %1-1, %2-1, %3-1, errvar
SET VAR vg_db = NULL
--EXIT --Use EXIT to drop out of RBase all-together
RETURN
ELSE
SET VAR vg_db = (CVAL('database'))
ENDIF
ELSE
--This connects using the user from the rbase.cfg file
CONNECT yourdatabase IDENTIFIED BY &vm_user
SET VAR vm_interr = .errvar
IF vm_interr <> 0 THEN
PAUSE +
FOR 2 USING 'ERROR: Could not connect to database' +
CAPTION 'Connection error' AT CENTER CENTER
CLEAR VAR vm_user, vm_interr
CLEAR VAR %1-1, %2-1, %3-1, errvar
SET VAR vg_db = NULL
RETURN
ELSE
SET VAR vg_db = (CVAL('database'))
ENDIF
ENDIF
CLEAR VAR vm_%
RETURNHere is some code to compile it --c2compil.rmd CODELOCK 5 cn2db.app cn2db.apx RETURN
Here is a command file to test it. --c2.tst RUN conn2db IN cn2db.apx USING firstname secondname thirdname RETURN
How this works..
When you pass in the users you want able to connect like the example above, or you can
change the file and hardcode them into the file like:
IF vm_user = 'USER1' OR vm_user = 'USER2' OR vm_user = 'USER3' THEN
Hope this helps Jim Limburg
Dan Champion wrote:
Hi all,
Does anyone have some good advice on the topic of Database Ownership. We just recently took our PUBLIC 'ly owned database, but now the company owner would like to be able to restrict access to one of the tables. I Set him as OWNER, and Granted access (table by table) to the users. Now... unload/reloads can't be done by anyone but the owner?
How do we set it back to public till we figure a better way to do this?
Thanks,
Dan
Dan Champion P.O. Box 223 Grandville, MI. 49428-0223 www.championsolutions.net

