Kod: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Data.OleDb; namespace Login_Register { public partial class Form1 : Form { public Form1() { InitializeComponent(); } OleDbConnection con; OleDbCommand cmd; OleDbDataReader dr; private void guna2Button2_Click(object sender, EventArgs e) {
con = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source=kullanicilar.accdb"); cmd = new OleDbCommand(); con.Open(); cmd.Connection = con; cmd.CommandText = "SELECT * FROM users WHERE username='" + guna2TextBox7.Text + "' AND password='" + guna2TextBox8.Text + "'"; dr = cmd.ExecuteReader(); if (dr.Read()) { guna2TextBox7.Text = ""; guna2TextBox8.Text = ""; MessageBox.Show("Giriş başarılı, yönlendiriliyorsunuz.", "Gray Client", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (String.IsNullOrEmpty(guna2TextBox7.Text) || String.IsNullOrEmpty(guna2TextBox8.Text)) { MessageBox.Show("Kullanıcı adı veya parola alanı boş bırakılamaz!", "Gray Client", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("Kullanıcı adı ya da parola hatalı lütfen tekrar deneyin!", "Gray Client", MessageBoxButtons.OK, MessageBoxIcon.Warning); } con.Close(); } private void guna2Button3_Click(object sender, EventArgs e) { /*if (guna2TextBox5.Text != guna2TextBox4.Text) { MessageBox.Show("Parolalar uyuşmadı lütfen tekrar deneyin!", "Gray Client", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else {*/ cmd.CommandText = "INSERT INTO users(username,password,mail) VALUES (@username,@password,@mail)"; /////// HATA BURADA con.Open(); cmd.Parameters.AddWithValue("@username", guna2TextBox3.Text); cmd.Parameters.AddWithValue("@password", guna2TextBox4.Text); cmd.Parameters.AddWithValue("@mail", guna2TextBox6.Text); cmd.ExecuteNonQuery(); //Hata var. MessageBox.Show("Kayıt başarılı, yukarıdan ilgili bilgileri girerek oyunu oynayabilirsiniz.", "Gray Client", MessageBoxButtons.OK, MessageBoxIcon.Information); /*}*/ } private void Form1_Load(object sender, EventArgs e) { con = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source=kullanicilar.accdb"); cmd = new OleDbCommand(); cmd.Connection = con; } } } |
Bildirim