Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connect to database... problem

Status
Not open for further replies.

misterimran

Programmer
May 13, 2002
19
0
0
PK
Hi Friends,
I have made a form based on a control block. Block contains two non database items.
TXT_USER and TXT_PASSWORD. I have placed a button on this form with name LOGIN_BTN.
Now I want my user to connect to the databases they want to. For example it user Type SCOTT in TXT_USER field and TIGER in TXT_PASSWORD then he must logon to Scott/tiger user and can access the tables and view.
I am writing this code in my WHEN-BUTTON-PRESS event of the button.

IF :Login_Blk.Txt_User IS NOT NULL AND
:Login_Blk.Txt_Password IS NOT NULL THEN

LOGON:)Login_Blk.Txt_User,:Login_Blk.Txt_Password||'@'||'ORCL_DEVP');
Call_Form('EMP.FMX');
END IF;

in my LOGON trigger of the form where i am taling User Name and Password from the user- I have written NULL.

ON-LOGON trigger
NULL;

When EMP form is called and I try to execute the query EMP forms gives an error.
FRM-40514 Operation requires a database connection.

I also want to handle the exception is user enters wrong User and Password. Then how can I generate message of wrong user or password? Is there any exception to write in the exception par of the block?

Please solve my problem.
Best regards,
Mirza Imran Baig
 
Can you explain the reason of suppressing ON-LOGON trigger? Sure, you can not query data without connection to database :)
You may either pass TRUE as a third parameter to get both error message and logon screen or just check FORM_SUCCESS status.

Regards, Dima
 

Hello Dima,

well the reason why i wanna surpress on-logon trigger is cuz i dont want to show the default logon screen before the form get starts. i want that from my developed form the user must give user name and passowrd and then login to database. cuz i have given some other options too on the same form.

can you kindly write some code? what will you write in the when button press event if you want your user to connect to anydatabse and how will you handle error by FORM_FAILURE event?

Pliz help,
Imran
 
You must logout from current user before changing the connection.
Please try below code...

IF :)Login_Blk.Txt_User IS NOT NULL AND
:Login_Blk.Txt_Password IS NOT NULL) THEN

logout; --To logout from current user before changing conn.

LOGON :)Login_Blk.Txt_User,:Login_Blk.Txt_Password||'@'||
'ORCL_DEVP',FALSE);

END IF;

if form_success then
message ('current user '||user);
Call_Form('EMP.FMX');

else
set_alert_property('Alt_Warn',alert_message_text,
'Invalid username/Password');
n_alt:=show_alert('alt_warn');
end if;

Regards
Shahzad Zafar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top