gokilavasan m

gokilavasan m

  • NA
  • 51
  • 37k

help regarding session

Apr 27 2012 3:51 AM
How to use session in login page.In my login page i have 2labels(username,password),2 textboxes and 1button.

the following code is my login page using stored proc.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection("Data Source=ATSSERVER\\SQLEXPRESS;Initial Catalog=arun;User ID=sa;Password=mis@12345");
    
    protected void Page_Load(object sender, EventArgs e)
    {
      
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("chkusr",con);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter s1 = new SqlParameter("@username", TextBox1.Text);
        SqlParameter s2 = new SqlParameter("@password", TextBox2.Text);
        cmd.Parameters.Add(s1);
        cmd.Parameters.Add(s2);
        SqlDataReader dr = cmd.ExecuteReader();

        if (dr.HasRows)
        {
            Response.Write("Login Success");
        }
        else
        {
            Response.Write("Login failed");
        }
   

    }
}




Answers (1)