ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sql server login prompt (https://www.excelbanter.com/excel-programming/369355-sql-server-login-prompt.html)

Isabel_ve

Sql server login prompt
 
Is it possible to prevent that the 'sql server login'-prompt will be shown
when it's not possible to make a connection to the database?

It is not our purpose that our users know the userid and password. When
they can't make a connection to the database they have to restart the
application (excel-file) or press our refresh connection-state button. I
just want to show a messagebox 'Could not make a connection to the database'
instead of the 'sql server login'-prompt.

Does someone know if it is or how it's possible?

TIA,


Isabel

tony h[_161_]

Sql server login prompt
 

Some clarification from you would be helpful as to how you are accessing
the SQL database.

From your comments I guess you are setting up a connecting on startup
and have a refresh connection button but that the code can terminate
and so you lose your connection.

In this situation if you test the connection or database object eg:

if cnn is nothing then do_the_reconnection_code

Although this should work it does imply that you are not closing
objects properly. To manage this Set up a class object to handle the
connection and other database objects. Then define a global variable AS
NEW myCLASS.

The advantage of thios is that you can automatically manage the opening
and closing of the connection through the class initialise and class
terminate events.

If you want help on this post again - or I have posted similar
responses before.

hope this helps.

regards


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=568231



All times are GMT +1. The time now is 04:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com