Solved

Sql Server 2005 Connection Error

Posted on 2007-11-26
3
161 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

839 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