472,143 Members | 1,161 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 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 3561
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John Shadel | last post: by
reply views Thread by Tor Inge Rislaa | last post: by
5 posts views Thread by James | last post: by
1 post views Thread by NEWS | last post: by
13 posts views Thread by AAaron123 | last post: by
reply views Thread by leo001 | last post: by

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.