TAILIEUCHUNG - Creating a Table in the Database from a DataTable Schema

[ Team LiB ] Recipe Creating a Table in the Database from a DataTable Schema Problem You need to create a table in a database from an existing DataTable schema. Solution Use the CreateTableFromSchema( ) method shown in this solution. | Team LiB Recipe Creating a Table in the Database from a DataTable Schema Problem You need to create a table in a database from an existing DataTable schema. Solution Use the CreateTableFromSchema method shown in this solution. The sample code contains one event handler and two methods Creates a DataTable containing the schema from the Orders table in the Northwind sample database. The method CreateTableFromSchema in the sample code is called to create a table in the database from this schema. CreateTableFromSchema This method creates a schema in the database for the schema of the DataTable argument. The method builds a DDL statement from the schema information and executes it against the data source specified by the connection string argument to create the table. NetType2SqlType This method is called by the CreateTableFromSchemaMethod to map .NET data types to SQL Server types when building the DDL statement. The C code is shown in Example 10-15. Example 10-15. File Namespaces variables and constants using System using using using using using . . . private void goButton_Click object sender e Fill a table with the Orders table schema. String sqlText SELECT FROM Orders SqlDataAdapter da new SqlDataAdapter sqlText S ql_ConnectString DataTable dt new DataTable Orders dt CreateTableFromSchema dt S ql_ConnectString Table TABLENAME created. Create DataTable from schema. private void CreateTableFromSchema DataTable dt String connectionString Drop the new table if it is already there. StringBuilder sqlCmd new StringBuilder if exists SELECT FROM WHERE id object_id TABLENAME AND OBJECTPROPERTY id IsUserTable 1 .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.