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 ShowData
{
public partial class Form1 : Form
{
Dataset ds;
OleDbCommand cmd;
OleDbConnection con;
OleDbDataAdapter da;
OleDbCommandBuilder cb;
public Form1()
{
InitializeComponent();
}
private void btnShow_Click(Object Sender,EventArgs e)
{
//filling the dataadapter with data(Student is only the nameofthe
//datagrid at runtime) using the dataset
da.Fill(ds,"Student");
}
private void Form1_Load(Object Sender,EventArgs e)
{
con = new OleDbConnection("DataSource = d:\\Student.mdb;Provider = Microsoft.Jet.OleDb4.0");
cmd = new OleDbCommand("select*from student",con);
da = new OleDbDataAdapter();
da.SelectCommand = cmd;
cb = new OleDbCommandBuilder();
cb.DataAdapter = da;
ds = new Dataset();
//binding the datagrid to the dataset
this.dataGrid1.DataSource = ds;
}
}
}