• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

How to handle a stored procedure that returns variable number of fields

Hi experts,

We need to handle in asp.net a report (data grid or html table) that shows the result from a stored procedure that returns a variable number of fields, it's about a statistics report (crosstab), so depending the pivot column the user selects the sp will return a diferent number of fields:

by city:

product, city1, city2, city3
product A, $100.00, $500.00, $400.00
product B, $3200.00, $4500.00, $4400.00

by year:

product, 2001, 2002, 2003, 2004, 2005
product A, $100.00, $500.00, $400.00, $4500.00, $1400.00
product B, $3200.00, $4500.00, $4400.00, $2500.00, $2400.00

we won't be able to predict the number of fields, it will depend on the data,

we need some idea how to handle this in a efficent way...

Thanks in advance

Carlos V.
0
CARLOSVILLACRIZ
Asked:
CARLOSVILLACRIZ
1 Solution
 
WebSpecialsCommented:
yes....

you can do that easily with a data Adapter (available for most databases)

then you fill a DataSet with the returned value of the Stored Procedure.

if you bind it to a DataGrid an choose "AutoGenerateColumns" the component will handel that itself how many columns to generate

hope that solves your problem

cu WebSpecials
0
 
CARLOSVILLACRIZAuthor Commented:
thanks webspecials, it's the right way...
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now