Solved

Sql Server 2005 Connection Error

Posted on 2007-11-26
3
158 Views
Last Modified: 2010-03-19
I am using the following connection string
"Data Source=(local);Initial Catalog=PAINT_DBS;Integrated Security=true"

Getting the Below Error. Not sure how to fix this.  I am using Sql Server 2005 Express.  My windows application would be installed on several machines which will have their own local database. So I am using the above connection string. GEtting the below error.

{"An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"}
0
Comment
Question by:AdibRahman77
  • 2
3 Comments
 
LVL 17

Expert Comment

by:Chris Mangus
ID: 20351412
Instead of coding your Data Source as (local) try servername\sqlexpress
0
 

Author Comment

by:AdibRahman77
ID: 20351535
I want this value to be dynamic. My application would be installed on several  machines.  I would not know the servername and sql server name in advance.
So I tried to use local to make it independent of the actual name. But this gives the above error.

0
 
LVL 17

Accepted Solution

by:
Chris Mangus earned 500 total points
ID: 20351616
You can retrieve the server name from the environment variable via VBA.ENVIRON$("COMPUTERNAME").  If you install SQL Express with all default options then the instance name is always SQLExpress.

Alternatively, you would need to use SQL Server Configuration Manager to set an alias to the local machine.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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