wie ktos moze jak sprawdzić jaki jest wynik zapytania.? tzn chce przypisać ten wynik do zmiennej i go wyświetlić...Pomoże mi ktos??
Oto kod..
private bool UserLogin(string userName, string password)
{
string conString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(conString))
{
SqlCommand com = new SqlCommand("SELECT login FROM uzytkownik WHERE Login = @login AND Haslo = @haslo", con);
// set the username and password parameters
com.Parameters.Add("@login", SqlDbType.NVarChar).Value = userName;
com.Parameters.Add("@haslo", SqlDbType.NVarChar).Value = password;
con.Open();
string result = Convert.ToString(com.ExecuteScalar());
if (string.IsNullOrEmpty(result))
{
return false;
}
else
{
return true;
}
}
}
protected void Zaloguj_Click(object sender, EventArgs e)
{
this.Label1.Visible = true;
string userName = this.Login.Text;
string password = this.Haslo.Text;
bool result = UserLogin(userName, password);
if ((result))
{
this.Label1.Text = "zalogowano poprawnie jako pracownik/kierownik";
}
else { this.Label1.Text = "bład w logowaniu"; }
}
protected void Page_Load(object sender, EventArgs e)
{
this.Label1.Visible = false;
}
</script>