Đang chuẩn bị liên kết để tải về tài liệu:
Creating and Using a DataViewManager Object
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Creating and Using a DataViewManager Object To create a DataViewManager, you use one of the following constructors: DataViewManager() DataViewManager | Creating and Using a DataViewManager Object To create a DataViewManager you use one of the following constructors DataViewManager DataViewManager DataSet myDataSet where myDataSet specifies the DataSet used by the DataViewManager object. This sets the DataSet property of the new DataViewManager object to myDataSet. Let s take a look at an example of creating and using a DataViewManager. Assume you have a DataSet named myDataSet which contains a DataTable populated with rows from the Customers table. The following example creates a DataViewManager object named myDVM passing myDataSet to the constructor DataViewManager myDVM new DataViewManager myDataSet The next example sets the Sort and RowFilter properties that will be used later when a DataView for the Customers DataTable is created myDVM.DataViewSettings Customers .Sort CustomerlD myDVM.DataViewSettings Customers .RowFilter Country UK Note The previous code doesn t actually create a DataView it merely sets the properties of any DataView created in the future that views rows from the Customers DataTable. The following example actually creates a DataView by calling the CreateDataView method of the myDVM DataViewManager passing the customersDT DataTable to CreateDataView DataView customersDV myDVM.CreateDataView customersDT The Sort and RowFilter properties of the customersDV DataView are set to CustomerlD and Country UK respectively. These are the same settings as those set earlier in the DataViewSettings property. Listing 13.4A shows a complete example that creates and uses the DataViewManager shown in this section. Listing 13.4A USINGDATAVIEWMANAGER.CS UsingDataViewManager.es illustrates the use of a DataViewManager object using System using System.Data using System.Data.SqlClient class UsingDataViewManager public static void Main SqlConnection mySqlConnection new SqlConnection server localhost database Northwind uid sa pwd sa SqlCommand mySqlCommand mySqlConnection.CreateCommand mySqlCommand.CommandText SELECT