could not open a connection to sql server

  • I am using sql server 2005 and asp.net 2.0 in my home.

    I established connection in my application and put code in page load

    protected void Page_Load(object sender, EventArgs e)

    {

    string constring = "server=.\\SQLEXPRESS;uid=sa;pwd=;data source=dbAshok";

    //Open the connection

    sqlconnection = new SqlConnection(constring);

    sqlconnection.Open();

    string strquery = "select *from Employee";

    dataset = new DataSet(strquery);

    sqlconnection.Close();

    }

    But i got an error in open the connection. My error is below.

    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)

    I couldn't fix this bugs. Please suggest me.

    Hope yours reply.

  • By default SQL Server Express does not allow remote connections. Go into the SQL Server Configuration Manager and make sure you have either NamedPipes or TCP enabled in the SQL Server 2005 Network Configuration.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply