How to determine progmm. SQL Server connection

Greetings, I’m working on a project wherein I have to determine just-in-time when user tries to connect to Axapta whether a valid connection to SQL Server is there or not, If not then I have to dynamically change the config to point it to the next available SQL Server. The whole objective behind this is: I have a primary SQL Server which is online and have a standby SQL Server which is a real-time copy of the primary server. Now, when my primary server is down, I want to automatically change my SQL Server config(Axconfig) to point to standby server. How far I have come: 1. I tried to raise some events in application.startup() and info.startup()…But both these are not useful, since they are fired after user logon. 2. I tried some simulation technique like stopping SQL Service and then logging on from Axapta, it throws exception, but as per my knowledge I cannot handle this exception within Axapta code becoz I think this logic might be embedded in .dll files which are shipped with Axapta and nowhere there’s no logging done by Axapta for this connection error even though the error message says “please see the log for further details” Is this true? Please confirm. 3. I also tried using SQL profiler but of no use becoz as soon as I stop SQL Service, the profiler too stops. Another thing, i opened Axapta and was browsing through some modules and in the middle, I purposely detached the database from SQL Server, at that time Axapta throws a dialog saying that “The connection to SQL is broken…etc etc”…but nowhere this is tracked in log files or something. Any ideas?? 3. I tried dependecy walker to check how the ax32.exe is linked. I observed that when SQL Server is not running Ax32 cant map to sqlsr32.dll. so i think the logic for determining SQL state is embedded in some dll’s. Please Correct me if i’m wrong. So finally it sums up to me that I should write some program outside Axapta, like batch file or sql script or something which will notify me whenever SQL Server goes down and accordingly change my axconfig to standby SQL Server. I just wanted to know from you guys if there’s any possibilty within Axapta to dynamically determine the SQL Server state? If any, Please suggest or let me know so that I will go the Axapta way instead of rather crooked way :wink: Regards, Dilip

Update: Guys, I don’t believe it’s possible from within Axapta so I created a scheduled program which will check for my SQL Connectivity and on connection failure, programmatically i’m switching my primary.axc file to secondary.axc file so it will silently failover to standby server config without any user intervention. Regards, Dilip