using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        OleDbConnection bag;
        OleDbCommand komut1, komut2;
        string ks;
        string sql, sql2;
        OleDbDataReader oku1;

        sql = "SELECT COUNT(*) FROM Kullanicilar WHERE Mail='" + TextBox1.Text + "' and Sifre='" + TextBox2.Text + "'";
        sql2 = "SELECT * FROM Kullanicilar WHERE Mail='" + TextBox1.Text + "' and Sifre='" + TextBox2.Text + "'";
        bag = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("App_Data/BSoylu.mdb") + "");
        komut1 = new OleDbCommand(sql, bag);
        komut2 = new OleDbCommand(sql2, bag);
        bag.Open();
        ks = komut1.ExecuteScalar().ToString();
        if (ks == "1")
        {
            oku1 = komut2.ExecuteReader();
            while (oku1.Read())
            {
                
                Session["Giris"] = "Yapıldı";
                Session["Adi"] = oku1["Adi"].ToString();
                Session["Soyadi"] = oku1["Soyadi"].ToString();
                Session["ID"] = oku1["ID"].ToString();
                Response.Redirect("Default.aspx");
                oku1.Close();
            }
        }
            else
            {
                Label1.Text = "Kullanıcı Bulunamadı";
            }
      
    }
}