Solved

best practice for SQL connection string?

Posted on 2012-03-20
6
654 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
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.

 
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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jquery datatables, asp.net MVC 9 38
Modal Popup Extender control 1 18
Cannot Change Local DNS 9 42
Need help how to find where my error is in UFD 6 26
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
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…
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 …

813 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

14 Experts available now in Live!

Get 1:1 Help Now