|
using System;
using System.Data;
using System.Windows.Forms;
using System.Reflection;
using System.Data.OleDb;
namespace MethodlarinTeknikKullanimi
{
public partial class Form1 : Form
{
OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DB.mdb;");
public Form1()
{
InitializeComponent();
connection.Open();
}
public void OgrencileriListele()
{
string aktifMethodAdi = MethodInfo.GetCurrentMethod().Name;
using (OleDbCommand command = new OleDbCommand(aktifMethodAdi, connection))
{
using (DataTable table = new DataTable())
{
command.CommandType = CommandType.StoredProcedure;
table.Load(command.ExecuteReader());
dataGridView1.DataSource = table.DefaultView;
}
}
}
public void OgretmenleriListele()
{
string aktifMethodAdi = MethodInfo.GetCurrentMethod().Name;
using (OleDbCommand command = new OleDbCommand(aktifMethodAdi, connection))
{
using (DataTable table = new DataTable())
{
command.CommandType = CommandType.StoredProcedure;
table.Load(command.ExecuteReader());
dataGridView1.DataSource = table.DefaultView;
}
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
connection.Close();
}
private void btnOgrenciListele_Click(object sender, EventArgs e)
{
OgrencileriListele();
}
private void btnOgretmenListele_Click(object sender, EventArgs e)
{
OgretmenleriListele();
}
}
}
|