public partial class Home_AlumniLogin : System.Web.UI.Page
{
    Buildconnection c = new Buildconnection();
    public string conn = ConfigurationSettings.AppSettings["dsn"];
    public string str = "Data Source=S-90E1F156B1BF4\\SQLEXPRESS;uid=a;database=college";
    public SqlConnection con;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {

          con = new SqlConnection(conn); 
          string str = "select ID1 from student where ID1='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'";
          con.Open();  
          SqlCommand cmd = new SqlCommand(str, con);
          string a = Convert.ToString(cmd.ExecuteScalar());

        if (a == "")
        {
            Message.Text = "User Not Found";
        }
        else 
        {
            Session["ID1"] = a;
            Response.Redirect("../Student/AlumniHome.aspx");

        }

       
    }
}

I got an error at con.Open();
please help me....it's very urgent....

Recommended Answers

All 3 Replies

Could we at least be told what the error is?

Without knowing the details of your error, I would say that your connection string (conn) is incomplete. Here is a great reference site for constructing connection strings, but I would say that you may need to provide a Password or Integrated Security setting?

commented: Agree! :) +15

give details of an ERROR

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.