Follow @rb_rudra

Friday 5 April 2013

Visual Studio 2008 users please help? I'm a beginner in Visual Studio 2008...I just want to create a login page by asp.net web application with two buttons login and register .. first v have to get user details to register them and then store their info in a database and only the register user can be able to login the site..... pls help me in using the database tables for storing during registration and checking during login ...... Here I use C# language in it......... pls do help me...

add following on web config...here enter your server name, databse name, etc.
<connectionStrings>
<add name="dbcon" connectionString="server=RUDRA-PC\SQLEXPRESS;uid=sa;pwd=123456;database=library;"/>
</connectionStrings>


on button click....

protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {

            string str1 = "select * from signup where username='" + TextBox1.Text + "' and password  ='" + TextBox2.Text + "'";
            String con = ConfigurationManager.ConnectionStrings["dbcon"].ConnectionString;
            SqlConnection con1 = new SqlConnection(con);

            con1.Open();
            SqlDataAdapter da1 = new SqlDataAdapter(str1, con);
            DataSet ds1 = new DataSet();
            da1.Fill(ds1);
            if (ds1.Tables[0].Rows.Count > 0)
            {
                Session["user"] = TextBox1.Text;
                Response.Redirect("home.aspx");

            }
            else
            {
                Label4.Text = "INCORRECT PASSWORD/USER NAME!";

            }
            con1.Close();
        }
        catch
        {
            Label4.Text = "DATABASE DOES NOT EXIST";
        }
       

No comments:

Post a Comment