A quick little tip on how to manage connection strings in your applications with a SQL Alias that you can create with “SQL Server Configuration Manager”
If you have a specific connection string in your application.config like
<connectionStrings> <add name="NorthwindConnectionString" connectionString="Data Source=MyLittleLaptop\SQLExpress; Initial Catalog=Northwind; Persist Security Info=True; User ID=userName;Password=password" providerName="System.Data.SqlClient" /> </connectionStrings>
In order to avoid
#1 merge conflicts on every check in
#2 to remember to exclude the app.config (or web.config) on every check in
Figure: Exclude the app.config because I needed to change the DB connectionstring to “.\SQLExpress”
#3 getting beaten by other developers
Create a SQL Alias with SQL Server Configuration Manager
- Open SQL Configuration Manager
- Go to “SQL Native Client 10.0 Configuration (32bit)”
My client is a 32bit process
- Create a new alias
In my case called: “.\USTER” since that is DB name that we agreed on
Figure: “.\USTER” points to “.\MSSQL” via Named Pipes - Ready to rock!
Make sure to enable “Named Pipes” for that SQL instance
Happy days in your development team!
BTW: If you deploy your application to different environments you can and should change server names via “XML transforms” or “XML Parametrizations”
5 comments:
Thanks for this
We do have this problem.
#3 happens frequently :)
I had similar experience in this order: #1 and #2... and finally #3 :-)
This article is based on Microsoft SQL Server, and Transact-SQL, but that is of little importance, as most of the concepts can be equally applied to other database technologies.
Hi Basil
>>as most of the concepts can be equally applied to other database technologies.
In other database technologies you need to use different techniques.
Can you share some?
DNS entries? VMWare virtualization that points to different servers...
Thanks for sharing such valuable information.
Post a Comment