From: Martin R. <ne...@mi...> - 2003-10-01 14:36:44
|
Hi, I found some info in help in Visual studio 2003 use this topic: "Setting Up DataTable and DataColumn Mappings [C#]" If you do not specify a TableName or a DataTableMapping name when calling the Fill or Update method of the DataAdapter, the DataAdapter will look for a DataTableMapping named "Table". If that DataTableMapping does not exist, the TableName of the DataTable will be "Table". You can specify a default DataTableMapping by creating a DataTableMapping with the name of "Table". The following code example creates a DataTableMapping (from the System.Data.Common namespace) and makes it the default mapping for the specified DataAdapter by naming it "Table". The example then maps the columns from the first table in the query result (the Customers table of the Northwind database) to a set of more user-friendly names in the Northwind Customers table in the DataSet. For columns that are not mapped, the name of the column from the data source is used. [C#] DataTableMapping custMap = custDA.TableMappings.Add("Table", "NorthwindCustomers"); custMap.ColumnMappings.Add( "CompanyName", "Company"); custMap.ColumnMappings.Add( "ContactName", "Contact"); custMap.ColumnMappings.Add( "PostalCode", "ZIPCode"); custDA.Fill(custDS); |