Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

best practice for SQL connection string?

Posted on 2012-03-20
6
655 Views
Last Modified: 2012-04-13
My IIS7 ASP.NET website is hosted on the same Win 2008 server as my SQL 2008 R2 database.

My web applications have my SQL connection string in the web.config file.  It looks like this:

connectionString="Data Source=mydomain.com.....

Would connections speed up if I did something like DataSource = Localhost or the private-side IP, or something like that?   Is what Im doing the best practice?  I favor browsing speed for the end user (web visitor) above all else
0
Comment
Question by:arthurh88
6 Comments
 
LVL 39

Expert Comment

by:Aaron Tomosky
ID: 37745839
I always use localhost mainly because it makes it easy to copy from dev to staging to production. It makes it technically faster because there is no DNS lookup but I don't think you would notice as its cached after the first time.
0
 
LVL 6

Expert Comment

by:SJCFL-Admin
ID: 37747194
From my perspective, this is best practice in terms of scalability:

Plan on ultimately having seperate application and SQL servers

Use DNS because eventually you will may need to change physical configuration and ultimately this will cause least interruption to your users
0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 37747274
Please do not use Localhost. This is bad practise.

Use ServerName exactly. Even IP leads to confusion sometimes.

Better store encrypted string in web.config file where you can decrypt in application for security purpose.

http://www.codeproject.com/Tips/304638/Encrypt-or-Decrypt-Connection-Strings-in-web-confi
http://chiragrdarji.wordpress.com/2008/08/11/how-to-encrypt-connection-string-in-webconfig/
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 39

Accepted Solution

by:
Aaron Tomosky earned 500 total points
ID: 37747630
The reason I use localhost is because the only thing that talks to my db is a small app that has all the web services. It always lives on the db server. My actual front end applications don't have connection strings to the database.

I suppose if you have everything as one big application it would be bad practice to do it this way, but then I would consider it bad practice to have one big application ;)
0
 
LVL 6

Expert Comment

by:SJCFL-Admin
ID: 37747904
You are one step ahead of me and I salute you ! :-)
0
 

Author Comment

by:arthurh88
ID: 37759174
why is local host a bad practice?  can someone explain that please?
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A procedure for exporting installed hotfix details of remote computers using powershell
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question