?
Solved

best practice for SQL connection string?

Posted on 2012-03-20
6
Medium Priority
?
683 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
[X]
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
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 39

Accepted Solution

by:
Aaron Tomosky earned 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

801 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