A network-related or instance-specific error occurred while establishing a connectio

Discussion in 'Databases' started by Gord, May 17, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am Having a problem connecting to Sql Server 2008
    I generated a backup from Sql Swerver 2005 - there were no errors reported when I restored it to my sql server database on your server.
    I can access the table(s) data no probs using the littleAdmin query tool

    below is the web.config code fragmant, as well as the code fragment which the app is crashing on

    Any help would be greatly appreciated!!!

    note: this is my first attempt at loading a database on your servers

    Thanks
    Gord




    /*********************************************************

    web.config:

    <appSettings>
    <add key="ConnectionString" value="Data Source=tcp:sql2k803.discountasp.net;Initial Catalog=SQL2008_99999_MyAccount;User ID=SQL2008_99999_MyUser;Password=MyPassword;" />

    </appSettings>


    //********************************************************

    use of connection string:

    string strConnection = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
    SqlConnection MyConn = new SqlConnection(strConnection);

    //define connection object
    //MyConn = new SqlConnection(ConnStr);

    MyQuery = "Select COUNT('ID') AS GlossaryPageCount From glossary";
    MyConn.Open();
    SqlCommand cmdGlossaryPage = new SqlCommand(MyQuery, MyConn);
    MyCount = Convert.ToInt32(cmdGlossaryPage.ExecuteScalar());
    GlossaryPageCount = MyCount;
    MyConn.Close();


    //********************************************************
    the Error:

    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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
    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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

    Source Error:

    Line 159:
    Line 160: MyQuery = "Select COUNT('ID') AS GlossaryPageCount From glossary";
    Line 161: MyConn.Open();
    Line 162: SqlCommand cmdGlossaryPage = new SqlCommand(MyQuery, MyConn);
    Line 163: MyCount = Convert.ToInt32(cmdGlossaryPage.ExecuteScalar());

    [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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
     
  2. any thoughts???
     
  3. ...Read my other response and then please provide some details. ;-)
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page