ADO.NET

ADO.NET Projects

ADO.NET Project 1

ADO.NET Examples

Examples

adplus-dvertising
Copy a DataTable
Previous Home Next

we can do copy of datatable with the help of copy();

private void button1_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\\student.mdb");
con.Open();
OleDbCommand cmd =new OleDbCommand("select * from marks", con);
DataTable tb = new DataTable();
tb.Load(cmd.ExecuteReader(CommandBehavior.CloseConnection));
DataTable copytable = tb.Copy();
tb = null;
dataGridView1.DataSource = copytable;
}
Previous Home Next