Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Hopefully this will be an easy one.

I have several projects that use a Sql Server 2012 instance on one of our cloud servers. When I am developing on that server my connection string must be .\SERVER_NAME but when I am connecting to it remotely the connection string must be IP_ADDRESS, PORT_NUMBER. I sometimes forget to change the connection string from local to remote when I push to the production environment.

Is there a way to make both the local and remote connection string the same? Also is there a way to avoid having the port number in the remote address?

Any help would be much appreciated.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

As for the port, the default SQL SERVER port is 1433, if that is the port you are sending then it isn't necessary. As for having one connectionstring or not changing the name you could do a couple of things I guess...

Here are some options:

  • Add a post deployment task where the correctly configured .config file is copied to the target.
  • Code machine specific connections, so both conn strings would be in the web/app .config and based on the runtime machine dictates what conn string you use.
  • Add an entry in your host file for the server, on dev it points to DEV Server while on the other sever it points to the other.

Not sure why you must use an IP address and not a name, you must not have any DNS?

share|improve this answer
1  
You are correct I do not have DNS services on the remote server. I am going to look into the hosts file option which is a great idea. –  schwietertj Jul 25 at 18:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.