Solved

best practice for SQL connection string?

Posted on 2012-03-20
6
664 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

738 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