Notes
Notes - notes.io |
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=veritabani.accdb;Persist Security Info=False;");
DataTable tablo = new DataTable();
OleDbCommand cmnd = new OleDbCommand();
OleDbDataReader dr;
panel pnl = new panel();
public List<string> bolum_kodlari = new List<string>();
public List<string> bolumler = new List<string>();
List<string> ogr_Ad = new List<string>();
List<string> ogr_Unvan= new List<string>();
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection xlsxbaglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + yol + "'; Extended Properties='Excel 12.0 Xml;HDR=YES'");
xlsxbaglanti.Open(); //Bağlantımızı açtık
tablo.Clear(); //Önceki verilerle karışmaması için tabloyu her tıklamada sıfırlıyoruz
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM [GENEL$]", xlsxbaglanti); //OleDbDataAdapter ile excel dosyamızdaki verileri listeliyoruz. Burada önemli olan kısım sorgu cümleciğinde ki Sheet1$ kısmı yerine excel dosyasındaki sayfa ismini yazmanız gerek. Bu isim excel dosyanızı açtığınızda en altta yazan isimdir. Eğer değiştirmediyseniz zaten Sayfa1 olarak yazar. Ayrıca " $ " simgesi ve köşeli parentezleri ellememeniz gerek.
da.Fill(tablo); //Gelen sonuçları datatable'a gönderiyoruz.
dataGridView1.DataSource = tablo; //datatable'da ki verileri datagrid'de listeliyoruz.
xlsxbaglanti.Close(); //Bağlantıyı kapatıyoruz.
MessageBox.Show(dataGridView1.Columns[6].ToString());
}
private void veri_aktar_Load(object sender, EventArgs e)
{
cmnd.Connection = conn;
}
string deger,kod;
int sayac=0,bul=0;
string ad_soyad, unvan;
string komut;
private void button2_Click(object sender, EventArgs e)
{
conn.Open();
cmnd.CommandText = "delete * from gorevli";
cmnd.ExecuteNonQuery();
for (int i = 1; i < dataGridView1.RowCount; i++)
{
try
{
ad_soyad = dataGridView1.Rows[i].Cells[2].Value.ToString();
unvan = dataGridView1.Rows[i].Cells[1].Value.ToString();
ad_soyad.Trim();
unvan.Trim();
cmnd.CommandText = komut;
cmnd.ExecuteNonQuery();
}
catch (Exception)
{
}
}
MessageBox.Show("İşlem tamamlandı veritabanını kontrol ediniz");
conn.Close();
}
private void button3_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = ".xlsx |*.xlsx| .xls|*.xls";
openFileDialog1.FilterIndex = 1;
openFileDialog1.RestoreDirectory = true;
openFileDialog1.Title = "Excel Dosyası Seçiniz..";
openFileDialog1.ShowDialog();
yol = openFileDialog1.FileName;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedItem=="Sınıflar")
{
komut = "insert into gorevli (ad_soyad,unvan) values ('" + ad_soyad + "','" + unvan + "')";
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team