473,388 Members | 982 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,388 software developers and data experts.

error while establishing a connection to the server


Using Vs2005 sqlServer 2005

When i try to connect i get this 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)

Connection string:
<connectionStrings>
<add name="pubsConnectionString1" connectionString="Data Source=.;Initial
Catalog=pubs;User=mk;pw=x"
providerName="System.Data.SqlClient" />
</connectionStrings>

Calling code :

try
{
using (SqlConnection cn = new
SqlConnection(WebConfigurationManager.ConnectionSt rings[0].ConnectionString))
{
cn.Open();

}

}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Jul 25 '06 #1
3 3604
You don't seem to be providing it with a data source to connec to.

"thom" wrote:
>
Using Vs2005 sqlServer 2005

When i try to connect i get this 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)

Connection string:
<connectionStrings>
<add name="pubsConnectionString1" connectionString="Data Source=.;Initial
Catalog=pubs;User=mk;pw=x"
providerName="System.Data.SqlClient" />
</connectionStrings>

Calling code :

try
{
using (SqlConnection cn = new
SqlConnection(WebConfigurationManager.ConnectionSt rings[0].ConnectionString))
{
cn.Open();

}

}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Jul 25 '06 #2
First, you need to determine whether "." (the local machine) is indeed valid
for that SQL Server instance. For example, it may actually be something like
".\SQLNAME".
Also, ensure the userid and password are correct, and that both Windows and
SQL Server authentication are enabled on the SQL Server.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"thom" wrote:
>
Using Vs2005 sqlServer 2005

When i try to connect i get this 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)

Connection string:
<connectionStrings>
<add name="pubsConnectionString1" connectionString="Data Source=.;Initial
Catalog=pubs;User=mk;pw=x"
providerName="System.Data.SqlClient" />
</connectionStrings>

Calling code :

try
{
using (SqlConnection cn = new
SqlConnection(WebConfigurationManager.ConnectionSt rings[0].ConnectionString))
{
cn.Open();

}

}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Jul 25 '06 #3
I just created a new site, i added a strongly typed ds to the app_data, the
connection string that was pub in my webconfig is:

<connectionStrings>
<add name="NorthwindConnectionString" connectionString="Data
Source=.;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>

and this works

so i created this code,,, and it works, thanks

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class ErrPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
string s = "Data Source=.;Initial Catalog=Northwind;Integrated
Security=True";
SqlConnection cn = new SqlConnection(s);
cn.Open();
Response.Write(cn.State);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}

}
}
"Peter Bromberg [C# MVP]" wrote:
First, you need to determine whether "." (the local machine) is indeed valid
for that SQL Server instance. For example, it may actually be something like
".\SQLNAME".
Also, ensure the userid and password are correct, and that both Windows and
SQL Server authentication are enabled on the SQL Server.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"thom" wrote:

Using Vs2005 sqlServer 2005

When i try to connect i get this 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)

Connection string:
<connectionStrings>
<add name="pubsConnectionString1" connectionString="Data Source=.;Initial
Catalog=pubs;User=mk;pw=x"
providerName="System.Data.SqlClient" />
</connectionStrings>

Calling code :

try
{
using (SqlConnection cn = new
SqlConnection(WebConfigurationManager.ConnectionSt rings[0].ConnectionString))
{
cn.Open();

}

}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Jul 25 '06 #4

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

Similar topics

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...
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.