C# - Yanlış Hata Bildirimi
-
- string kullaniciadi = txt_kadi.Text;
- string sifre = txt_sifre.Text;
- if (txt_kadi.Text != null & txt_sifre.Text != null)
- {
- MessageBox.Show("Kullanıcı adı ve Şifre girmediniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- try
- {
- if (kullaniciadi != null & sifre != null)
- {
- OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:/DB.mdb");
- OleDbCommand sorgu = new OleDbCommand("SELECT ID, Pass FROM Uyeler", baglanti);
- OleDbDataReader okuyucu;
- bool onay = false;
- try
- {
- baglanti.Open();
- okuyucu = sorgu.ExecuteReader();
- while (okuyucu.Read())
- {
- if ((kullaniciadi == okuyucu["ID"].ToString()) & (sifre == okuyucu["Pass"].ToString()))
- {
- onay = true;
- break;
- }
- }
- baglanti.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- if (onay == true)
- {
- Anaform ac = new Anaform();
- ac.Show();
- this.Hide();
- }
- }
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.ToString());
- }
- }
-------------
Müridler bu kodu giriş panelinde kullanmaktayız ancak bir sorunu var.Kullanıcı adı ve şifre kısmını boş bıraktığımızda "kullanıcı adı ve şifre yanlış" diyor."Kullanıcı adı ve şifre girmediniz" nasıl yazdırabiliriz?
-
4. satırdaki if (txt_kadi.Text != null & txt_sifre.Text != null)
bunu
if (txt_kadi.Text = null & txt_sifre.Text = null)böyle değiştir.
-
FCN bunu yazdı:
-----------------------------4. satırdaki if (txt_kadi.Text != null & txt_sifre.Text != null)
bunu
if (txt_kadi.Text = null & txt_sifre.Text = null)böyle değiştir.
-----------------------------Operator '&' cannot be applied to operands of type '<null>' and 'string'
dedi :|
-
yanlış hata değilde yanlış veya hata olur :) hep bu anlatım bozukluğu soruları :D
-
rapidhacker550 bunu yazdı:
-----------------------------yanlış hata değilde yanlış veya hata olur :) hep bu anlatım bozukluğu soruları :D
-----------------------------hocum türkçe sözdizimi değilde c# sözdizimine yardım edeydin iyiydi :)
-
tamam görmemişim = değil == olarak düzeltince olması lazım :|
-
HoneyBadger bunu yazdı:
-----------------------------rapidhacker550 bunu yazdı:
-----------------------------yanlış hata değilde yanlış veya hata olur :) hep bu anlatım bozukluğu soruları :D
-----------------------------hocum türkçe sözdizimi değilde c# sözdizimine yardım edeydin iyiydi :)
-----------------------------bilsek ederiz :)
-
rapidhacker550 bunu yazdı:
-----------------------------HoneyBadger bunu yazdı:
-----------------------------rapidhacker550 bunu yazdı:
-----------------------------yanlış hata değilde yanlış veya hata olur :) hep bu anlatım bozukluğu soruları :D
-----------------------------hocum türkçe sözdizimi değilde c# sözdizimine yardım edeydin iyiydi :)
-----------------------------bilsek ederiz :)
-----------------------------canın sağolsun :)
-
string kullaniciadi = txt_kadi.Text; string sifre = txt_sifre.Text; try { if (!string.IsNullOrEmpty(kullaniciadi) & !string.IsNullOrEmpty(sifre)) { OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:/DB.mdb"); OleDbCommand sorgu = new OleDbCommand("SELECT ID, Pass FROM Uyeler", baglanti); OleDbDataReader okuyucu; bool onay = false; try { baglanti.Open(); okuyucu = sorgu.ExecuteReader(); while (okuyucu.Read()) { if ((kullaniciadi == okuyucu["ID"].ToString()) & (sifre == okuyucu["Pass"].ToString())) { onay = true; break; } } baglanti.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (onay == true) { Anaform ac = new Anaform(); ac.Show(); this.Hide(); } } else { MessageBox.Show("Kullanıcı adı ve Şifre girmediniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception exp) { MessageBox.Show(exp.ToString()); } -
20.000 üyen olursa yavaşlıktan kimse sisteme giremez söylim :)
kodları bayağı bir değiştirmen lazım :)
-
DB Access zaten arkadaşın performans kaygısı yok gibi duruyor.
