D
David Jackson
Hello,
Firstly I apologise if this is the wrong newsgroup.
I am looking for a way to cross-tab / transform / pivot the data in a
DataTable fetched from a SQL Server stored procedure. Unfortunately, due to
company restrictions, I'm unable to modify the stored procedure or create a
different one.
The data is historical exchange rate data and, when fetched from SQL Server,
looks like this:
FxDate IsoCc FxRate
=====================
2009-07-01 AED 6.0533
2009-07-02 AED 6.0117
2009-07-03 AED 6.0029
2009-07-01 AUD 2.0401
2009-07-02 AUD 2.0578
2009-07-03 AUD 2.0442
2009-07-01 CAD 1.8921
2009-07-02 CAD 1.9004
2009-07-03 CAD 1.8950
....
....
....
The date range and currency range are chosen by the users at run-time.
Ideally, I would like to transform the above data so that it has the
following structure:
FxDate AED AUD CAD
============================
2009-07-01 6.0533 2.0401 1.8921
2009-07-02 6.0117 2.0578 1.9004
2009-07-03 6.0029 2.0442 1.8950
This transformed data will then be used as the datasource of a databound
control. There is no aggregation involved, simply a transformed arrangement
of the data.
A Google search reveals lots of examples of how to do this e.g.
http://redsouljaz.wordpress.com/2009/06/22/asp-net-cross-tab-pivot-from-data-table/
But I'm wondering if this is really the only way to do this? Perhaps there
is a more efficient method available, maybe with LINQ?
N.B. I'm not expecting anyone to write my code for me, but I would be
grateful for any guidance with choosing the most efficient method.
Thank you.
DJ
Firstly I apologise if this is the wrong newsgroup.
I am looking for a way to cross-tab / transform / pivot the data in a
DataTable fetched from a SQL Server stored procedure. Unfortunately, due to
company restrictions, I'm unable to modify the stored procedure or create a
different one.
The data is historical exchange rate data and, when fetched from SQL Server,
looks like this:
FxDate IsoCc FxRate
=====================
2009-07-01 AED 6.0533
2009-07-02 AED 6.0117
2009-07-03 AED 6.0029
2009-07-01 AUD 2.0401
2009-07-02 AUD 2.0578
2009-07-03 AUD 2.0442
2009-07-01 CAD 1.8921
2009-07-02 CAD 1.9004
2009-07-03 CAD 1.8950
....
....
....
The date range and currency range are chosen by the users at run-time.
Ideally, I would like to transform the above data so that it has the
following structure:
FxDate AED AUD CAD
============================
2009-07-01 6.0533 2.0401 1.8921
2009-07-02 6.0117 2.0578 1.9004
2009-07-03 6.0029 2.0442 1.8950
This transformed data will then be used as the datasource of a databound
control. There is no aggregation involved, simply a transformed arrangement
of the data.
A Google search reveals lots of examples of how to do this e.g.
http://redsouljaz.wordpress.com/2009/06/22/asp-net-cross-tab-pivot-from-data-table/
But I'm wondering if this is really the only way to do this? Perhaps there
is a more efficient method available, maybe with LINQ?
N.B. I'm not expecting anyone to write my code for me, but I would be
grateful for any guidance with choosing the most efficient method.
Thank you.
DJ