hi to all
can u pls send the code how to store login and logout time in database using sessions can u solve dis
below
snippet
SqlConnection con = new SqlConnection("Data Source=suhels;Initial Catalog=suhel1;User ID=sa;Password=abc");
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Login_Click(object sender, EventArgs e)
{
con.Open();
string q = "select Count(*) from memebers where username='" + TextBox1.Text + "' AND password ='" + TextBox2.Text + "'";
SqlCommand comm = new SqlCommand(q, con);
int result = (int)comm.ExecuteScalar();
if (result > 0)
{
String s = "insert into Logins('"+TextBox1.Text+"',DateTime.Now
cmd.Parameters.AddWithValue("@username",TextBox1.Text);
cmd.Parameters.AddWithValue("@logintime", DateTime.Now.ToShortDateString());
cmd.ExecuteNonQuery();
Session["User"] = TextBox1.Text.ToString();
cmd = new SqlCommand(s, con);
int r = cmd.ExecuteNonQuery();
}