lamont Posted June 24, 2015 Share Posted June 24, 2015 Arkadaşlar Nette Araştırdım dataGridView Kendini Otomatik Güncellemesi İçin Bir Metod Buldum Ama Hata Alıyorum Amacım Veritabanı Güncelledikten Sonra dataGridView Kendini Otomatik Yenileyip Güncel Bilgileri Göstermesini İstiyorum Kod Aşagıda void Listele() { DataContext dt = new DataContext(); dataGridView1.DataSource = dt.VeriGetir(); } Hata Mesajı 'System.Data.Linq.DataContext' does not contain a constructor that takes 0 arguments Quote Link to comment Share on other sites More sharing options...
ozhan3030 Posted June 25, 2015 Share Posted June 25, 2015 Arkadaşlar Nette Araştırdım dataGridView Kendini Otomatik Güncellemesi İçin Bir Metod Buldum Ama Hata Alıyorum Amacım Veritabanı Güncelledikten Sonra dataGridView Kendini Otomatik Yenileyip Güncel Bilgileri Göstermesini İstiyorum Kod Aşagıda void Listele() { DataContext dt = new DataContext(); dataGridView1.DataSource = dt.VeriGetir(); } Hata Mesajı 'System.Data.Linq.DataContext' does not contain a constructor that takes 0 arguments void Listele() { baglanti.Open(); SqlDataAdapter data_adp = new SqlDataAdapter("Select * From tablo", baglanti); DataSet ds = new DataSet(); data_adp.Fill(ds, "baglanti"); DataTable tablo1 = new DataTable(); data_adp.Fill(tablo1); dataGridView1.DataSource = tablo1; baglanti.Close(); } İstediğin şey kayıt eklediğinde datagride görüntülemekse yukarıdaki kod işini görür. Quote Link to comment Share on other sites More sharing options...
lamont Posted June 25, 2015 Author Share Posted June 25, 2015 malesef Update İşe Yaramıyor Denedim Başka Bir Çözüm Update Delete İnsert İçin ? Quote Link to comment Share on other sites More sharing options...
muratboy31 Posted June 29, 2015 Share Posted June 29, 2015 Kullandığım koddan bir örnek vereyim ; public void KAYIT_LISTELE() { SqlConnection mycon = new SqlConnection(); SqlCommand mycommand = new SqlCommand(); SqlDataAdapter adp = new SqlDataAdapter(mycommand); try { mycon.ConnectionString = Connect; mycon.Open(); mycommand.Connection = mycon; mycommand.CommandText = "sp_Kayit_Listele"; mycommand.CommandType = CommandType.StoredProcedure; DataTable dtable = new DataTable(); adp.Fill(dtable); gridControl1.DataSource = dtable; gridView1.Columns["ID"].Visible = false; gridView1.Columns["Teklif"].Caption = "İşin Tanımı"; gridView1.Columns["Departman"].Caption = "Departman"; gridView1.Columns["TalepNo"].Caption = "Talep No"; } catch (Exception e) { MessageBox.Show(Convert.ToString(e)); } finally { mycon.Close(); } } Quote Link to comment Share on other sites More sharing options...
Editor pairs Posted June 29, 2015 Editor Share Posted June 29, 2015 DataContext in constructor ı bir parametre alması gerekiyor sanırım. Yani tanımlarken. DataContext dt = new DataContext(parametre); gibi tanımlamak lazım sanırım. O parantez içerisinde ne gibi bir veri istiyor bakmak lazım. Quote Link to comment Share on other sites More sharing options...
lamont Posted June 29, 2015 Author Share Posted June 29, 2015 Pairs Veritabanı Güncellednigi Zaman Grid Kendini nasıl Günceller Yuakrıdaki Kod Öenemli değil ? Quote Link to comment Share on other sites More sharing options...
lamont Posted June 30, 2015 Author Share Posted June 30, 2015 Olay Basitmiş Aslında Kendim Çözdüm Datagrid İçin DataTable Tanımlıyoruz Metod DataTable Global Olmalı Datagrid Temizlemek İçin Sonra Formun Activated Olayına Clear Yapıyoruz metodu Çagrıyoruz Böylece Her Güncellemeye Bilgiler Yenileniyor Örnek Kodları Veriyorum Datagrid Formun Açılışında Veritabanındaki Bilgileri Okuyor DataTable dt = new DataTable(); // Sanal Tablomuzu Yenilemek İçin DataTable Global Tanımlıyoruz public void Listele() { SqlDataAdapter oku = new SqlDataAdapter("select * from urunler", connet.bag()); { oku.Fill(dt); dataGridView1.DataSource = dt; } oku.Dispose(); } daha Sonra Formun Activated Olayına Önce DataTable İçerigini Resetliyoruz Daha Sonra Metodumuzu Çagrıyoruz Böylece DataGrid Sürekli Kendini Yeniliyor private void Urun_Duzenle_Sil_Activated(object sender, EventArgs e) { dt.Clear(); // Sanal Tablomuzun İçerigini Temizledik Listele(); // Daha Sonra Güncellenen Sanal Tablomuzu Geri Çagırdık } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.