SAO CHÉP CẤU TRÚC CỦA MỘT DATATABLE

Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string chuoiketnoi = @"Integrated security = sspi;Initial Catalog = northwind;";
            SqlConnection connection = new SqlConnection(chuoiketnoi);
            connection.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = new SqlCommand("SELECT * FROM Employees", connection);
            DataSet ds = new DataSet();
            da.Fill(ds, "Employees");
            DataTable dtbTable = ds.Tables["Employees"];
            //Clone bảng dữ liệu
            DataTable dtbCloneTable = dtbTable.Clone();
            connection.Close();
            Console.WriteLine("Chung ta da hoan thanh cong viec sao chep cau truc");
        }
    }
}
SAO CHÉP CẤU TRÚC LẪN DỮ LIỆU VÀ DỮ LIỆU CỦA MỘT DATATABLE
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string chuoiketnoi = @"Integrated security = sspi;Initial Catalog = northwind;";
            SqlConnection connection = new SqlConnection(chuoiketnoi);
            connection.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = new SqlCommand("SELECT * FROM Employees", connection);
            DataSet ds = new DataSet();
            da.Fill(ds, "Employees");
            DataTable dtbTable = ds.Tables["Employees"];
            //Clone bảng dữ liệu
            DataTable dtbCopyTable = dtbTable.Copy();
            connection.Close();
            Console.WriteLine("Chung ta da hoan thanh cong viec sao chep cau truc va du lieu");
        }
    }
}
TRUY TÌM DỮ LIỆU TRONG MỘT DATATABLE
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string chuoiketnoi = @"Integrated security = sspi;Initial Catalog = northwind;";
            SqlConnection connection = new SqlConnection(chuoiketnoi);
            connection.Open();
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = new SqlCommand("SELECT * FROM Employees", connection);
            DataSet ds = new DataSet();
            da.Fill(ds, "Employees");
            //Sàng lọc data table view
            DataTable dtbEmployees = ds.Tables["Employees"];
            dtbEmployees.DefaultView.RowFilter = "LastName = 'Fuller'";
            //Rảo qua tất cả các hàng dữ liệu trên data table view
            for (int i = 0; i <= dtbEmployees.DefaultView.Count - 1; i++)
            {
                Console.Write(dtbEmployees.DefaultView[0].Row["EmployeeID"].ToString());
                Console.Write("\t" + dtbEmployees.DefaultView[0].Row["LastName"].ToString());
                Console.Write("\t" + dtbEmployees.DefaultView[0].Row["FirstName"].ToString());
                Console.Write("\t" + dtbEmployees.DefaultView[0].Row["BirthDate"].ToString());
                Console.Write("\t" + dtbEmployees.DefaultView[0].Row["Address"].ToString());
            }
            connection.Close();
            Console.WriteLine("\nHoan thanh viec tim kiem");
        }
    }
}