Solved

best practice for SQL connection string?

Posted on 2012-03-20
6
651 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 38

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
The curse of the end user strikes again      

You’ve updated all your end user’s email signatures. Hooray! But guess what? They’re playing around with the HTML, adding stupid taglines and ruining the imagery. Find out how you can save your signatures from end users today.

 
LVL 38

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now