C
Access Veritabanından Tablo İsimlerini Çekme
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 combobox_access_tablo { public partial class Form1 : Form { OleDbConnection baglanti= new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source= ticaretsade.mdb"); OleDbDataAdapter da; DataSet ds; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { baglanti.Open(); DataTable dt = baglanti.GetSchema("Tables"); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["TABLE_NAME"].ToString().Trim().Substring(0,4) !="MSys") { comboBox1.Items.Add(dt.Rows[i]["TABLE_NAME"]); } //www.hizhosting.com } baglanti.Close(); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string tablo = comboBox1.Text; string sorgu = "SELECT *FROM " + tablo; da = new OleDbDataAdapter(sorgu, baglanti); ds = new DataSet(); baglanti.Open(); da.Fill(ds, tablo); dataGridView1.DataSource = ds.Tables[tablo]; baglanti.Close(); } } }