Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Sức khỏe - Y tế
Văn bản luật
Nông Lâm Ngư
Kỹ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Giới thiệu
Đăng ký
Đăng nhập
Tìm
Danh mục
Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Y tế sức khỏe
Văn bản luật
Nông lâm ngư
Kĩ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Thông tin
Điều khoản sử dụng
Quy định bảo mật
Quy chế hoạt động
Chính sách bản quyền
Giới thiệu
Đăng ký
Đăng nhập
0
Trang chủ
Công Nghệ Thông Tin
Kỹ thuật lập trình
Copying Rows from One DataTable to Another
Đang chuẩn bị liên kết để tải về tài liệu:
Copying Rows from One DataTable to Another
Kim Phú
76
3
pdf
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
[ Team LiB ] Recipe 5.1 Copying Rows from One DataTable to Another Problem You have records in a DataTable that you need to copy to another DataTable. Solution Use the ImportRow( ) method of the DataTable to copy DataRow objects from one DataTable to another. | Team LiB Recipe 5.1 Copying Rows from One DataTable to Another Problem You have records in a DataTable that you need to copy to another DataTable. Solution Use the ImportRow method of the DataTable to copy DataRow objects from one DataTable to another. Three techniques for selecting records to copy are demonstrated in the following example Use the Rows property to access rows in the DataRowCollection of the DataTable using the row index. Use the Select method of the DataTable. Use the RowFilter property of a DataView for the DataTable. The sample code creates a source DataTable containing the Orders table from Northwind. A second empty target DataTable is created with the same schema. One of the three techniques as specified by the user is used to copy records from the source table to the target table. The C code is shown in Example 5-1. Example 5-1. File CopyRowsBetweenTablesForm.es Namespaces variables and constants using System using System.Configuration using System.Data using System.Data.SqlClient Table name constants private const String ORDERS_TABLE Orders Field name constants private const String ORDERID_FIELD OrderlD . . . Fill the source table with schema and data. SqlDataAdapter da new SqlDataAdapter SELECT FROM Orders ConfigurationSettings.AppSettings Sql_ConnectString DataTable dt new DataTable ORDERS_TABLE da.FillSchema dt SchemaType.Source da.Fill dt Clone the schema to the copy table. DataTable dtCopy dt.Clone if rowRadioButton.Checked Use ImportRow method to import the first three rows. for int i 0 i 3 i dtCopy.ImportRow dt.Rows i else if selectRadioButton.Checked Copy using result of Select method. foreach DataRow row in dt.Select ORDERID_FIELD 10300 dtCopy.ImportRow row else if filteredDataViewRadioButton.Checked Copy using result of filtered DataView. DataView categoryView dt.DefaultView categoryView.RowFilter ORDERID_FIELD 10300 AND ORDERID_FIELD 10400 for int i 0 i categoryView.Count i dtCopy.ImportRow categoryView i .Row Bind the default .
TÀI LIỆU LIÊN QUAN
Copying Rows from One DataTable to Another
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.