Hello so i wanna check on data base is user already logged in then if hes logged stop login in here is sample of my code thx for help.
protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
{
String name = ((Login)LoginView1.FindControl("Login1")).UserName;
SqlConnection source_db = new SqlConnection();
source_db.ConnectionString = ConfigurationManager.ConnectionStrings["source"].ConnectionString;//konfiguracja polaczenia z web.cfg
SqlCommand sql_polecenie3 = new SqlCommand("select Status from aspnet_Users where UserName='" + name + "';", source_db);
try
{
source_db.Open();//otwiera polaczenie
if ((int)sql_polecenie3.ExecuteScalar() == 1)
{
Label1.Visible = true;
}
else
{
Label1.Visible = false;
}
source_db.Close();//zamyka polaczenie
}
catch (Exception)
{
source_db.Close();//zamyka polaczenie
}
}