Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my application i am connecting SQL server data. I want to know that my application connected local data base or network database of SQL server.

What I have tried:

I searched for solution in net but came with some answers which are not suitable
Posted
Updated 1-Jul-19 1:21am
v2
Comments
Mehdi Gholam 1-Jul-19 7:11am    
Check your connection string.

1 solution

The easiest way to check - pretty much the only way - is to look at the connection string you are using in your code.
If it's "LOCALHOST", or starts with your computers name, it's local.
If it doesn't, it isn't.

But ... I wouldn't rely on that for deciding if you are in dev or release: I'd use very specific config files to make sure that dev is only ever going to access a dev DB. The last thing you ever, ever want is dev code running against a production DB: the possibilities for problems are far, far too great!
 
Share this answer
 
Comments
F-ES Sitecore 1-Jul-19 7:25am    
You also need to check for ".", and don't forget to handle instance names too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900