Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection baglan = new OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source= Northwind.mdb");
OleDbDataAdapter adp = new OleDbDataAdapter();
string sorgu = "Select * From Orders";
adp.SelectCommand = new OleDbCommand(sorgu, baglan);
DataSet ds = new DataSet();
baglan.Open();
adp.Fill(ds,"Orders");
dataGridView1.DataSource = ds.Tables[0];
baglan.Close();
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection baglan = new OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source= Northwind.mdb");
OleDbDataAdapter adp = new OleDbDataAdapter();
string sorgu = "Select * From Orders";
adp.SelectCommand = new OleDbCommand(sorgu, baglan);
DataSet ds = new DataSet();
baglan.Open();
adp.Fill(ds, "Orders");
DataView dv = new DataView(ds.Tables["Orders"]);
//OrderID sütununa göre sıralama yapacağız.
dv.Sort = "OrderID";
//Filtre ile OrderID 10323 den büyük 10330 dan küçük ID ler
//gösterilecek.
dv.RowFilter = "OrderID > 10323 and OrderID < style=""> ";
//DataView i DataGridView a kaynak gösterdik.
dataGridView1.DataSource = dv;
baglan.Close();
}
}
}
Bir makalenin daha sonuna geldik. Bir sonraki makalede görüşmek dileğiyle. Hoşçakalın. Bahadır ŞAHİN
0 comments:
Yorum Gönder