Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //MsAccess bağlantısı
            OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\kutuphane.accdb");

            con.Open();
            OleDbCommand kmt = new OleDbCommand();

            kmt.Connection = con;     //command connectiona bağlanıyor

            //query kodu
            kmt.CommandText = "SELECT *FROM kullanicilar where kullanici_adi='" + kullanici_adi.Text + "' AND kullanici_sifresi='" + kullanici_sifresi.Text + "'";
            OleDbDataReader oku = kmt.ExecuteReader();

            if (oku.Read())                //okuma gerçekleşiyorsa
            {
                this.Hide();               //mevcut formu gizle
                anamenu k = new anamenu(); // k adında yeni bir anamenu formu türet
                k.ShowDialog();            // yeni formu aç
            }
            else
            {
                MessageBox.Show("Kullanıcı adı ya da şifre yanlış");
            }
        }