0
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....

Edited by __avd: added [code] tags.

4
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by prit005
1

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?

Votes + Comments
Agree! :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.