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:
<connectionStri ngs>
<add name="Northwind ConnectionStrin g" connectionStrin g="Data
Source=.;Initia l Catalog=Northwi nd;Integrated Security=True"
providerName="S ystem.Data.SqlC lient"/>
</connectionStrin gs>
and this works
so i created this code,,, and it works, thanks
using System;
using System.Data;
using System.Configur ation;
using System.Collecti ons;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;
using System.Data.Sql Client;
public partial class ErrPage : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
try
{
string s = "Data Source=.;Initia l Catalog=Northwi nd;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:
<connectionStri ngs>
<add name="pubsConne ctionString1" connectionStrin g="Data Source=.;Initia l
Catalog=pubs;Us er=mk;pw=x"
providerName="S ystem.Data.SqlC lient" />
</connectionStrin gs>
Calling code :
try
{
using (SqlConnection cn = new
SqlConnection(W ebConfiguration Manager.Connect ionStrings[0].ConnectionStri ng))
{
cn.Open();
}
}
catch (Exception ex)
{
Response.Write( ex.Message);
}