Đang chuẩn bị liên kết để tải về tài liệu:
Executing SELECT Statements and TableDirect Commands phần 2

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Listing 8.3: SCHEMAONLYCOMMANDBEHAVIOR.CS /* SchemaOnlyCommandBehavior.cs illustrates how to read a table schema */ using System; using System.Data; using System | Listing_8.3 _SCHEMAONLYCOMMANDBEHAVIOR.CS_ SchemaOnlyCommandBehavior.es illustrates how to read a table schema using System using System.Data using System.Data.SqlClient class SchemaOnlyCommandBehavior public static void Main SqlConnection mySqlConnection new SqlConnection server localhost database Northwind uid sa pwd sa SqlCommand mySqlCommand mySqlConnection.CreateCommand mySqlCommand.CommandText SELECT ProductID ProductName UnitPrice FROM Products WHERE ProductID 1 mySqlConnection.Open pass the CommandBehavior.SchemaOnly constant to the ExecuteReader method to get the schema SqlDataReader productsSqlDataReader mySqlCommand.ExecuteReader CommandBehavior.SchemaOnly read the DataTable containing the schema from the DataReader DataTable myDataTable productsSqlDataReader.GetSchemaTable display the rows and columns in the DataTable foreach DataRow myDataRow in myDataTable.Rows Console.WriteLine nNew column details follow foreach DataColumn myDataColumn in myDataTable.Columns Console.WriteLine myDataColumn myDataRow myDataColumn if myDataColumn.ToString ProviderType Console.WriteLine myDataColumn System.Data.SqlDbType myDataRow myDataColumn productsSqlDataReader.Close mySqlConnection.Close You should notice the different details for the ProductID ProductName and UnitPrice columns in the output that follows New column details follow ColumnName ProductID ColumnOrdinal 0 ColumnSize 4 NumericPrecision 0 NumericScale 0 IsUnique IsKey BaseCatalogName BaseColumnName ProductID BaseSchemaName BaseTableName DataType System.Int32 AllowDBNull False ProviderType 8 ProviderType Int IsAliased IsExpression IsIdentity True IsAutoIncrement True IsRowVersion IsHidden IsLong False IsReadOnly True New column details follow ColumnName ProductName ColumnOrdinal 1 ColumnSize 40 NumericPrecision 0 NumericScale 0 IsUnique IsKey BaseCatalogName BaseColumnName ProductName BaseSchemaName BaseTableName DataType System.String AllowDBNull False ProviderType 12 ProviderType .

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.