locked
Sql Server 2008 connectivity error RRS feed

  • Question

  • User2083497229 posted

    My question may be simple but i have the following error ocurred in my code when i try to debug. 

    protected void Button1_Click(object sender, EventArgs e)
    {

    SqlCommand com;

    SqlDataReader dr;
    String connectionstr = "Server=(local)/SQLEXPRESS;Database=db_Logininformation;User Id= jananni-PC/jananni;Password=;";
    SqlConnection con = new SqlConnection(connectionstr);
    con.Open();
    com = new SqlCommand("select Password from userinformation where Username='" + TextBox1.Text + "'", con);
    dr = com.ExecuteReader();
    if (!dr.Read())
    {
    Response.Write("Invalid User");
    }
    else
    {
    if (dr[0].ToString() == TextBox2.Text)
    {
    Response.Redirect("~/mainPage.aspx");
    }
    else
    {
    Response.Write("Wrong Password");
    TextBox2.Focus();
    }
    }

    }

    The error shown is :con.Open(); 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)

    Thursday, January 24, 2013 9:15 PM

Answers

  • User-1716253493 posted
    String connectionstr = "Server=./SQLEXPRESS;Database=db_Logininformation ..........
    


    Change (local) to dot

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 24, 2013 10:08 PM