#1
|
|||
|
|||
What SQL server and databases are open?
Word VBA newbie...
User is running an application that uses MS SQL server. The program can either be using a test database on the back-end or a production database. While in the program they start Word. Word is the way they get data into certain parts of the program since they are using Word to create a report that will be stored in the database. I have written a .dotm that is in the users Word StartUp folder. I query the database using macros in the macro enabled template. The issue is that someone could open Word using either the test database or the production database on multiple servers. Since my application queries the database to get certain information I need to know whether they are using the test database or the production database and which server they are located on. I can tell by the name of the database whether they are in the test database or the production database. The test database and production databases could be on the same server or a different server. Is there a way to use VBA and find out the name of any open SQL databases and the server they are located on? That way I could open the correct database to get the information I need. Thank you... |
#2
|
||||
|
||||
IMHO, you're going about this the wrong way. If the SQL is supposed to work with a particular database, the code should used a fully-qualified database name; not simply work with whatever 'production' database the user has open.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
I appreciate the concern but...
Is it possible to find the "open" databases and the server on which they reside with VBA? If so how?
|
#4
|
||||
|
||||
To do that, you would have to search all servers for databases, then test whether anyone has them open. This is irrelevant to the question of which database the user running an SQL is using.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
How do I test if the database is open?
There is a only a small number of databases I would have to search. How can I use VBA and tell if the database is open?
|
#6
|
||||
|
||||
See, for example: http://support.microsoft.com/kb/209189
However, given that many databases allow multi-user access, simply know that 'someone' has such a database open isn't of much use, since that doesn't prevent someone else opening the same database; all that gets locked in such instances are the records in use.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Formula to open external file with specific program (like open with) | pemartins | Excel | 16 | 02-24-2014 11:39 PM |
Save in SERVER instead. | zuzullo | Outlook | 3 | 09-08-2011 12:34 AM |
unable to open .RTF files in server machine from client machine | Naresh_1210 | Word | 0 | 03-12-2010 03:26 AM |
Exchange Server. Do I need it? | SRE | Outlook | 1 | 01-11-2010 06:36 PM |
Can I use one VERY big server for everything ? | RickH | Project | 0 | 12-15-2005 08:22 AM |