How to catch the and publish yourself the message?
-
I am writing an application in VB6 to interface with SQL 6.5 and have a question regarding catching login failure messages. The first thing my application does is prompt the user for his SQL userid and password. I then try to login to SQL Server. If the user entered a wrong password, the Microsoft SQL Server Login failed message is displayed.This message contains too much technical information that will confuse the users. I would like to trap the error and send my own screen with more user friendly information. The exact error message is 'Connection Failed: SQL State: '28000' SQL Server Error 4002. Public Connection As String Public DBTemp As Database Connection = "odbc;logintimeout=30;DSN=Station Train Control;" Set DBTemp = OpenDatabase("", True, False, Connection) Please help! Lillian.
-
I am writing an application in VB6 to interface with SQL 6.5 and have a question regarding catching login failure messages. The first thing my application does is prompt the user for his SQL userid and password. I then try to login to SQL Server. If the user entered a wrong password, the Microsoft SQL Server Login failed message is displayed.This message contains too much technical information that will confuse the users. I would like to trap the error and send my own screen with more user friendly information. The exact error message is 'Connection Failed: SQL State: '28000' SQL Server Error 4002. Public Connection As String Public DBTemp As Database Connection = "odbc;logintimeout=30;DSN=Station Train Control;" Set DBTemp = OpenDatabase("", True, False, Connection) Please help! Lillian.
Why don't you place the code in a Boolean function, then trap it like followed: private function connect_to_db(Connection as string) as boolean on error goto failed_open set DBTemp = OpenDataBase("",true,false,Connection )'Public connect_to_db = true exit function failed_open: if err.number = 28000 then msgbox "Wrong Password Or User name, please try again" connect_to_db=false exit function end function Hoped to have helped you : :-O Rayman