Click here to Skip to main content
15,354,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<connectionstrings>
    <add name="CongString">
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|MBH_DB.mdf;User Instance=true;"
         providerName="System.Data.SqlClient" />;
    </add></connections
trings>br mode="hold" />;
i use above connection string


Server Error in '/' Application.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5066458
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +341
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +129
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +270
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +5080107
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
System.Data.SqlClient.SqlConnection.Open() +125
mbh.Login.Logincheck(String UserName, String Pasword) in C:\Users\Minhas\Desktop\Test\mbh\mbh\Login.cs:28
mbh._Default.Button1_Click(Object sender, EventArgs e) in C:\Users\Minhas\Desktop\Test\mbh\mbh\Default.aspx.cs:30
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1016


[edit]SHOUTING removed, code block added, HTML encoded - OriginalGriff[/edit]
Posted
Updated 9-Dec-13 8:37am
v3
Comments
   
Does this Conmection String work at your local?
kashifjaat 9-Dec-13 14:25pm
   
"data source=MBH; This is work for local host
kashifjaat 9-Dec-13 14:26pm
   
login.mbh.com.pk
   
Have you placed the mdf file on server?
kashifjaat 9-Dec-13 14:35pm
   
FOR LOCAL HOST I USE THIS ONE ITS WORK FINE
<connectionstrings>
<add name="CongString" connectionstring="Data Source=Minhas-PC;Initial Catalog=MBH_DB;Integrated Security=True;Integrated Security=True;" providername="System.Data.SqlClient">
OriginalGriff 9-Dec-13 14:38pm
   
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.
chetan B Y 10-Dec-13 4:49am
   
Hi, friend

one clarification, are you using linq dbml file to connect database.
kashifjaat 10-Dec-13 4:52am
   
sql server 2008
chetan B Y 10-Dec-13 4:53am
   
no, i am asking are you using ado.net or linq

It is highly likely that the web host will have a FAQ that will describe how your connection string should look: it is unlikely that it will be the same as the one that you use locally to develop.

You can also take a look at the link below as it describes a large number of connection string options and other useful information.

The Connection Strings Reference[^].
   
Hi kashifjaat,

Could you please kindly check your connection string again? Could you please kindly check with your current provider that you have used the correct connection string?
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900