Link to home
Start Free TrialLog in
Avatar of ssptkt
ssptkt

asked on

Suppress oracle logon dialog in VB4

Hi
  I have trying to do a ODBC Oracle Connection using the logon screen created by VB forms and command button and textboxes.
I have a command button named connect.it contain the following codes:

connect="ODBC;....DSn......"
set db=opendatabase("",false,false,connect)

I'm supposed to use my logon screen to capture user id and password,
but the moment I key in an invalid oracle user id and password, oracle logon screen will be invoked.What I want is that my logon screen will be invoked (to let user try again) instead of the oracle logon.So is there anyway we can suppress that oracle logon.Please help.
Avatar of terencebeh
terencebeh

1. Put a error trapping. In the sub that you have the OpenDatabase statement, add in the following:

Private Sub ...
On Error Goto ErrorHandler
..
connect="ODBC;....DSn......"
set db=opendatabase("",false,false,connect)


ErrorHandler:
' Try to find out what is the error number that represent the  invalid login
    For iCnt = 0 to Errors.Count - 1
        msgbox errors(iCnt).Number
        msgbox errors(iCnt).Description
    Next

' Once you have find out the error number use the following:
    for iCnt = 0 to Errors.Count - 1
        if Errors(iCnt).Number = ???
              frmLogin.Show
        endif
    next
End Sub

Try stepping through your code by using F8 key.



Avatar of ssptkt

ASKER

Hi terencebeh:
   I haved tried your codes, but it doesn't seems to work.

Private Sub Command1_Click()
Dim gstr_connect As String
Dim gdb_data As Database
Dim iCnt As Integer
On Error GoTo ErrorHandler

gstr_connect$ = "ODBC;DSN=oracle;UID=" & text1.Text & " ;PWD=" & text2.Text & ";"
Set gdb_data = OpenDatabase("", False, False, gstr_connect$)

//The moment I finish stepping through the above step
//set gdb_data=......., my oracle logon screen will invoke
//There is no way I can reach the error handler unless I click //cancel at the oracle logon screen. It's only then I got the error number 3059 and message "Operation canceled by user"      
     
ErrorHandler:
For iCnt = 0 To Errors.Count - 1
MsgBox Errors(iCnt).Number
MsgBox Errors(iCnt).Description
Next iCnt
     
End Sub
ASKER CERTIFIED SOLUTION
Avatar of tward
tward

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial