Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bad connection does not raise error event
Message
 
À
26/08/2002 16:00:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00693801
Message ID:
00693818
Vues:
20
Hi,

do this before connecting:
SQLSETPROP(0, "DispLogin", 3)
See help file for details.

Regards,
Armin

>Hello Group,
> When I pass a bad username and password to the following code I get the messagebox that "Connection Failed" but the error handler was not involked. When I send correct username and password it connects. Why isn't an error raised. I am reading Doug Hennig as we speak but it is sinking in slowly.
>
>Thanks
>Jim
>
>lParam lcServer, lcUserID, lcPassword, lcDatabase
>Local lnHandle,lcConnect
>
>ON ERROR DO ODBCErrorHandler
>
>lcConnect= "DRIVER={SQL Server};Server=" + lcServer + ";UID=" + lcUserID + ";PWD=" + lcPassword + ";Network=DBMSSOCN;" + "DATABASE=" + lcDatabase + ";"
>
>lnHandle = SQLSTRINGCONNECT(lcConnect)
>
>
>IF lnHandle < 1 then && No Connection was made
>
> MESSAGEBOX("Connection Failed")
> RETURN 0
>
>ELSE && connection made return the connection Handle
>
> RETURN lnHandle
>
>ENDIF
>
>ON ERROR
>
>PROCEDURE ODBCErrorHandler
>LOCAL lcErrorString
>
>=AERROR(eray)
>lcErrorString = "Error Number " + alltrim(str(eray(1)))
>MessageBox(lcString)
>
>ENDPROC && ODBCErrorHandler
>
>lParam lcServer, lcUserID, lcPassword, lcDatabase
>Local lnHandle,lcConnect
>
>ON ERROR DO ODBCErrorHandler
>
>lcConnect= "DRIVER={SQL Server};Server=" + lcServer + ";UID=" + lcUserID + ";PWD=" + lcPassword + ";Network=DBMSSOCN;" + "DATABASE=" + lcDatabase + ";"
>
>lnHandle = SQLSTRINGCONNECT(lcConnect)
>
>
>IF lnHandle < 1 then && No Connection was made
>
> MESSAGEBOX("Connection Failed")
> RETURN 0
>
>ELSE && connection made return the connection Handle
>
> RETURN lnHandle
>
>ENDIF
>
>ON ERROR
>
>PROCEDURE ODBCErrorHandler
>LOCAL lcErrorString
>
>=AERROR(eray)
>lcErrorString = "Error Number " + alltrim(str(eray(1)))
>MessageBox(lcString)
>
>ENDPROC && ODBCErrorHandler

Armin Neudert
Regional Director (Stuttgart) of German FoxPro User Group dFPUG

MCP for Visual FoxPro

Expert/Editor of the VFP section in the German Codezone community portal
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform