0% found this document useful (0 votes)
41 views3 pages

C#Database Connectivity

Uploaded by

sg391405
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views3 pages

C#Database Connectivity

Uploaded by

sg391405
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

C#.

Net Database Connectivity and DataGridView Control:

using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];

namespace DB_Connect1
{
public partial class Form1 : Form
{
OleDbConnection con = new
OleDbConnection(@"Provider=[Link].12.0;Data Source=C:\Users\Hall
211\Desktop\DB_Connect1.accdb");
OleDbCommand cmd = new OleDbCommand();
OleDbDataAdapter da = new OleDbDataAdapter();
DataSet ds = new DataSet();
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
//[Link]("Connection Established");
show();

private void button1_Click(object sender, EventArgs e)


{
[Link] = "insert into Table1(ID,Name,Address,Mob)values(" +
[Link] + ",'" + [Link] + "','" + [Link] + "'," +
[Link] + ")";
[Link] = con;
[Link]();
[Link] = null;
[Link]();
[Link] = null;
[Link]();
[Link]("Record Saved Successfully");
clear();
show();
}

private void button3_Click(object sender, EventArgs e)


{
[Link] = "update Table1 set Name='" + [Link] +
"',Address='" + [Link] + "',Mob=" + [Link] + " where ID=" +
[Link] + "";
[Link] = con;
[Link]();
[Link]();
[Link]();
[Link]("Record Updated Successfully");
show();
}

private void button2_Click(object sender, EventArgs e)


{
[Link] = "delete from Table1 where ID=" + [Link] +
"";
[Link] = con;
[Link]();
[Link]();
[Link]();
[Link]("Record Deleted Successfully");
show();
}
void clear()
{
[Link]();
[Link]();
[Link]();
[Link]();
}
void show()
{
ds = new DataSet();
[Link] = "select *from Table1";
[Link] = con;
[Link]();
da = new OleDbDataAdapter([Link], con);
[Link](ds);
[Link] = [Link][0];
[Link]();
}

private void button4_Click(object sender, EventArgs e)


{
[Link]();
}
}
}
MS-Access Database

Output:

You might also like