Soran
Access Bu liste temizlenemez hatası

Soru
-
Herkese iyi günler. Access veritabanında bu programı yazdım ama arama özelliğini çalıştırdığımda Bu liste temizlenemez hatası alıyorum. Kodları aşağıya bırakıyorum. Lütfen yardım edin.(Button5 arama kısmı)
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 Eggs_Yumurtacılık_Resmi_Uygulaması { public partial class Form2 : Form { public Form2() { InitializeComponent(); } OleDbConnection baglanti = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0;Data Source = Yumurta.accdb"); private void Form2_Load(object sender, EventArgs e) { OleDbDataAdapter da = new OleDbDataAdapter("select * from Bilgi", baglanti); DataTable tab = new DataTable(); da.Fill(tab); dataGridView1.DataSource = tab; } private void button1_Click(object sender, EventArgs e) { using (OleDbConnection con = new OleDbConnection(baglanti.ConnectionString)) using (OleDbCommand komut = new OleDbCommand()) { komut.Connection = baglanti; komut.CommandText = @"INSERT INTO Bilgi (Musteri,Telefon,YumurtaTuru,KoliSayi,Adres,Numara) VALUES (@Musteri,@Telefon,@YumurtaTuru,@KoliSayi,@Adres,@Numara)"; komut.Parameters.Add("@Musteri", OleDbType.VarChar).Value = textBox1.Text; komut.Parameters.Add("@Telefon", OleDbType.VarChar).Value = textBox2.Text; komut.Parameters.Add("@YumurtaTuru", OleDbType.VarChar).Value = textBox3.Text; komut.Parameters.Add("@KoliSayi", OleDbType.VarChar).Value = textBox4.Text; komut.Parameters.Add("@Adres", OleDbType.VarChar).Value = textBox5.Text; komut.Parameters.Add("@Numara", OleDbType.VarChar).Value = textBox6.Text; baglanti.Open(); komut.ExecuteNonQuery(); baglanti.Close(); } DataTable tab = new DataTable(); OleDbDataAdapter da = new OleDbDataAdapter("Select * from Bilgi", baglanti.ConnectionString); da.Fill(tab); dataGridView1.DataSource = tab; MessageBox.Show("Başarıyla Eklendi"); } private void button2_Click(object sender, EventArgs e) { baglanti.Open(); OleDbCommand cmd = new OleDbCommand("delete from Bilgi where Numara = @Numara",baglanti); cmd.Parameters.Add("@Numara", textBox7.Text); cmd.ExecuteNonQuery(); cmd.Dispose(); baglanti.Close(); cmd.Dispose(); MessageBox.Show("Başarıyla Silindi"); DataTable tab = new DataTable(); OleDbDataAdapter da = new OleDbDataAdapter("Select * from Bilgi", baglanti.ConnectionString); da.Fill(tab); dataGridView1.DataSource = tab; } private void button3_Click(object sender, EventArgs e) { } private void button4_Click(object sender, EventArgs e) { MessageBox.Show("Bu program Ömer Serhat Şahan tarafından Eggs Yumurtacılık için programlanmıştır. Tüm hakları saklıdır."); } private void button3_Click_1(object sender, EventArgs e) { MessageBox.Show("Veri eklemek bilgileri yazın ve Ekle butonuna basın. Silmek için Silinecek kişi kısmını doldurup Sil butonuna basın. Eğer satırlar yetmiyorsa aşağıdaki verilerin gösterildiği yerden satırları uzatabilirsiniz. "); } private void textBox1_TextChanged(object sender, EventArgs e) { } private void button5_Click(object sender, EventArgs e) { OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Bilgi WHERE Musteri=@Musteri", baglanti); da.SelectCommand.Parameters.AddWithValue("@Musteri", textBox8.Text); DataTable dt = new DataTable(); baglanti.Open(); da.Fill(dt); baglanti.Close(); dataGridView1.Rows.Clear(); } } }
- Düzenleyen seri13 23 Mart 2019 Cumartesi 08:47
Tüm Yanıtlar
-
dataGridView1.Rows.Clear(); // yerine: dataGridView1.DataSource = null; dataGridView1.DataSource = dt;
yazmak istedin gibi geldi.
Not: Kizma ama kimse ciddi bir uygulama icin access'i database diye kullanmaz, er ya da geç basını agritir, sadece ne zaman agritacagini bilemezsin.
- Yanıt Olarak Öneren Mehmet Emin Kaymaz 23 Mart 2019 Cumartesi 09:35