DataAdapter and DataTableMapping defaults don't match

  • Thread starter Thread starter Philippe Bertrand
  • Start date Start date
P

Philippe Bertrand

DataAdapter uses "Table", "Table1", "Table2", ... as the default table names
and "Column1", "Column2", ... as the default name for unnamed source columns

but

DataTableMapping uses "SourceTable1", "SourceTable2", ... as the default
table mapping names and "SourceColumn1", "SourceColumn2", ... as the default
source column name

hence you can't quickly map unnamed columns

da = new DataAdapter( "SELECT MIN(SomeCol), MAX(SomeCol) FROM SomeTable",
conn );
DataTableMapping dtm = da.TableMappings.Add( "", "" ); // Defaults
"SourceTable1", ""
dtm.ColumnMappings.Add( "", "Min" ); //
results "SourceColumn1", "Min"
dtm.ColumnMappings.Add( "", "Max" ); //
results "SourceColumn2", "Max"
da.Fill( dataSet ); // adds
Table "Table" with "Column1", "Column2"

Why is that? Or is MSDN Oct 2004 wrong? (.NET Framework 1.1)

Thanks,
Philippe
 
Try modifying your SQL command to include specific column names instead of
using unnamed source columns.

SELECT MIN(SomeCol) as SomeColMin, MAX(SomeCol) as SomeColMax FROM SomeTable
 
I am aware of that. I just wanted to know why the defaults don't match up.

Philippe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top