Foxhound is the better* Database Monitor for SQL Anywhere.
*better: More thorough, more relevant, more effective.
...more Alerts, more All Clears, more details, more control in your hands.


Breck Carter
Last modified: December 9, 1996
mail to: bcarter@bcarter.com
[Home]



Tip 55: The ConnectOption DBParm Parameter

How do I suppress the standard ODBC dialog box that appears when the user enters the wrong password? I want my program to handle it.

Here's what this annoying dialog box looks like:


Look up "ConnectOption" in the PowerBuilder Help and you'll see that a whole new hierarchy of ODBC parameters has been added with PowerBuilder 5. One of these new parameters, called "SQL_DRIVER_CONNECT", has a value "SQL_DRIVER_NOPROMPT" which tells the ODBC driver to return an error if anything goes wrong with the connect statement.

Here's an example of the ConnectOption string embedded within a DBParm value:

 string ls_user_id
 string ls_password

 // Code to fill user id and password goes here.
 // e.g., ls_user_id = "DBA"
 //       ls_password = "garbage"

 SQLCA.DBMS = "ODB"
 SQLCA.DBParm = "ConnectString='DSN=MyData;UID=" &
    + ls_user_id &
    + ";PWD=" &
    + ls_password &
    + "',ConnectOption='SQL_DRIVER_CONNECT,SQL_DRIVER_NOPROMPT'"

 connect using SQLCA;
 if SQLCA.SQLCode <> 0 then
    MessageBox ( "Error", "Connect failed" )
    halt
 end if

 MessageBox ( "Error", "Connect OK" )


Breck Carter can be reached by phone at (416) 763-5200 or via email at bcarter@bcarter.com.