Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Letting calling program handle error messages.
Message
 
 
À
26/08/2002 10:47:45
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00693650
Message ID:
00693655
Vues:
23
You set properties firss and than establish connection.
* Suppress ODBC error dialog
IF SQLGETPROP(0,'DispWarnings')
= SQLSETPROP(0,'DispWarnings',.F.)  && No errors
ENDIF
*!*	*You can also suppres login dialog if needed
IF SQLGETPROP(0,'DispLogin') <> 3
	= SQLSETPROP(0,'DispLogin',3)  && No login -- error on fail
ENDIF

lnHandle = SQLSTRINGCONNECT(lcConnect)
>Hello Group,
>
>I am trying to use a class to make my connections to a SQL 7.0 database.
>I would like to suppress the error messages from the class and let the calling program handle the error.
>I would also like to suppress the logon screen that pops up when a logon fails.
>
>The code for my class is:
>
>lcConnect= "DRIVER={SQL Server};Server=" + lcServer + ";UID=" + lcUserID + ";PWD=" + lcPassword + ";Network=DBMSSOCN;" + "DATABASE=" + lcDatabase + ";"
>
>lnHandle = SQLSTRINGCONNECT(lcConnect)
>
>* Suppress ODBC error dialog
> IF SQLGETPROP(0,'DispWarnings')
> = SQLSETPROP(0,'DispWarnings',.F.) && No errors
> ENDIF
> *!* *You can also suppres login dialog if needed
> IF SQLGETPROP(0,'DispLogin') <> 3
> = SQLSETPROP(0,'DispLogin',3) && No login -- error on fail
> ENDIF
>
>IF lnHandle < 1 then
>
> MESSAGEBOX("Connection Failed")
> RETURN 0
>
>ELSE
> RETURN lnHandle
>ENDIF
>
>ON ERROR
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform