error: 40 - Could not open a connection to SQL Server

Discussion in 'ASP.NET 2.0' started by mysticimages, Jun 3, 2006.

  1. Hi Everyone,
    I hope that you can help. I just copied my first asp app here at discountAsp and I've run into an error I'm not sure how to handle. After the copy and navigating to the site I get the following 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: 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: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

    Source Error:





    Code:
    Line 105:
    Line 106:        Dim ds as DataSet = new DataSet()
    Line 107:        asDep.Fill(ds, "Department")
    Line 108:        asCat.Fill(ds, "Category")
    Line 109:




    On the MS site they seen to point to the options for the proptals, but not sure how I would change those here. At this time I'm assuming that its something else. Here is my connect string:


    connectionString="Server=SQL2005_2????_myserver;Initial Catalog=MyCatalog;Integrated Security=True"


    Have any suggestions. Thanks for any pointers.


    Michael Lee
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    I assume your application is trying to connect to one of our SQL 2k5 server.

    THe connection string you are using is wrong.

    Server= {this should be the SQL server name}
    Initial Catalog = {this should be the database name}
    Integrated Security = {this should be false because we use SQL authentication}

    The connection string should look something like this

    'Data Source=DBSERVERNAME;Initial Catalog=YOURDBNAME;User ID=YOURUSERID;Password=YOURPASSWORD'

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     

Share This Page