473,406 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

An error has occurred while establishing a connection to the server


I have written a webservice locally, and upon consuming or testing it
in the explorer there is a problem.
It throws the following exception:

System.Data.SqlClient.SqlException: 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).

I think the problem seems to be with the connection string. Here is
it:

public static string connectionString = @"server=amirdiwan;database=|
DataDirectory|\BankingDb.mdf;";

I havent sepcifed the exact directory as the db lies my desktop
folder. Should i write that instead of just DataDirectory? Should I
write the servername as "amirdiwan" which i got from hostname from my
console or "localhost" which is the name of the webreference that i
added?

Please, somebody rephrase my connection string.....

Would be grateful.

Jun 2 '07 #1
4 5351
hi,

you can use osql utility on command prompt : osql -E -
Stcp:servername\instancename or
Jun 2 '07 #2
or you can add Network=DBMSSOCN to your connectionstring

Jun 2 '07 #3
On Jun 2, 7:31 pm, Hakan Fatih YILDIRIM <hfysilis...@gmail.comwrote:
or you can add Network=DBMSSOCN to your connectionstring
You mean this is what my connectionstring should be:

public static string connectionString =
@"Network=UIC;server=amirdiwan;database=|DataDirec tory|
\BankingDb.mdf;";

If the code does not know where exactly the db lies, how will fetch
it? Is there some built-in fetching inside the compiler?

Please explain in detail....

Thankyou

Jun 3 '07 #4
On 3 Cze, 22:54, weird0 <amiredi...@gmail.comwrote:
On Jun 2, 7:31 pm, Hakan Fatih YILDIRIM <hfysilis...@gmail.comwrote:
or you can add Network=DBMSSOCN to your connectionstring

You mean this is what my connectionstring should be:

public static string connectionString =
@"Network=UIC;server=amirdiwan;database=|DataDirec tory|
\BankingDb.mdf;";

If the code does not know where exactly the db lies, how will fetch
it? Is there some built-in fetching inside the compiler?

Please explain in detail....

Thankyou
As far as I know Not in a compiler but it is build in system
(windows). I have other problem I am usling SMO library
and try to enumerate sql server services in loop find my
instance MYCOMP\FOTOPROG using such code

ManagedComputer mc = new ManagedComputer(sServerName);

string sMessage = "";
foreach (Service svce in mc.Services)
{
sMessage += String.Format("{0} -- {1} -- {2} -- {3} --
{4}\n",
svce.DisplayName, svce.Name, svce.ServiceAccount,
svce.ServiceState, svce.StartMode);
}

System.Windows.Forms.MessageBox.Show(sMessage, " " + mc.Name);

but it only get in mc.Services and shows to me two services
MSSQL$SQLEXPRESS (login type .\tomaszk ) and SqlBrowser (login type
NT AUTHORITY\NetworkService) but no my instance which is MSSQL
$FOTOPROG
and is on a service list and is started (login by .\tomaszk and also
with local
system acount
And I do not know why it does not work and tryin to investigate it and
lern
about this all acounts and privileges and also SMO and WMI for rev
about five
days

TIA
KENOBI

Jun 4 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chris Love | last post by:
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...
7
by: deltalimagolf | last post by:
I now get the following error message after copying an asp.net application to the deployment web server. I don't have SQLExpress or any version of SQL 2005 installed. I found the "LocalSQLServer"...
1
by: John Shadel | last post by:
I have the following setup: 1. ASP.NET 2.0 web app hosted on a web server (inetpub directory hosting physical files of the web site on a different drive name, E: than the SQL Server Instance,...
0
by: Tor Inge Rislaa | last post by:
Just for testing deployment of an asp.net application to the remote server I have crated an application based on the StarterKit application in Visual Studio 2005. When trying to run the...
5
by: James | last post by:
Hello, I have written a simple logon page that redirects to another page when successful. All works fine on my computer but when I upload it I get the error message below. I have written it...
1
by: NEWS | last post by:
My application is giving error .pls help . error : Server Error in '/webpdms' Application. -------------------------------------------------------------------------------- An error has...
1
by: =?Utf-8?B?TWljaGFlbA==?= | last post by:
Hi, I have a working site on my desktop. I tried to move it to production and I am getting an error on my new server. It has something to do with setting a profile. Here is the error. ...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ...
5
by: Cirene | last post by:
I just deployed my new ASP.NET (3.5 FW) site to the hosting company I'm using, webhost4life. NOTE: I HAVE deployed other SQL Server sites to the same account with no issues. Now I'm getting...
13
by: AAaron123 | last post by:
I downloaded the personal website starter kit and when I run it I get the error shown below. I found a way of using Launch Surface Area Configuration that is supposed to fix the remote setting...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.