using System.
Data;
using System.Data.OleDb;
namespace WinFormsApp2
{
public partial class Form1 : Form
{
OleDbConnection vcon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=D:\data.accdb");
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string s1 = "select * from [t1]";
OleDbCommand vcomm = new OleDbCommand(s1, vcon);
DataSet vds = new DataSet();
OleDbDataAdapter vda = new OleDbDataAdapter(vcomm);
vda.Fill(vds, "res");
dataGridView1.DataSource = vds.Tables["res"];
vda.Dispose();
vcomm.Dispose();
private void Form1_Load(object sender, EventArgs e)
{
vcon.Open();
}
private void button2_Click(object sender, EventArgs e)
{
string vsql = string.Format("insert into [t1] values('{0}','{1}')", textBox1.Text, textBox2.Text);
OleDbCommand vcomm = new OleDbCommand(vsql, vcon);
vcomm.ExecuteNonQuery();
MessageBox.Show("Added successful");
vcomm.Dispose();
private void button3_Click(object sender, EventArgs e)
{
string s2 = string.Format("select * from [t1] where [id]={0}", textBox3.Text);
//string s2 = "select * from Order where Roll_No='1010'";
OleDbCommand vcom = new OleDbCommand(s2, vcon);
DataSet vd = new DataSet();
OleDbDataAdapter vdap = new OleDbDataAdapter(vcom);
vdap.Fill(vd, "res");
dataGridView2.DataSource = vd.Tables["res"];
vdap.Dispose();
vcom.Dispose();
private void label1_Click(object sender, EventArgs e)
{
}
}
}