How to get a dynamic temp table into a 2003 .NET dataset

  • Thread starter Thread starter mrflynn
  • Start date Start date
M

mrflynn

Hi all,

I'm trying to use a SQL Server 2005 stored procedure in Visual Studio
2003 and am running into problems. The stored proc creates a temp
table dynamically where the number of columns and column names change
depending on the passed parameters.

The stored proc runs fine in SSMS. From the .NET side, all I want to
do is use the stored proc to create a csv download of the information
returned.

Any help is appreciated. Thanks.

-Orcabelle
 
Get the return as a generic dataset and you can output rather easily by
looping through rows and columns. Something like this (have not checked
validity of the items in this code, so you will have to tweak it):

foreach(DataRow row in ds.Tables[0].Rows)
{
foreach(DataColumn column in ds.Tables[0].Columns)
{
string valueToOutput = row[column.ColumnName];
}
}

You can output to a StringBuilder if you have to display as well as save.
For save only, you can output directly to a writer. To have the user
download, link to the file you have created. Guids are good for guaranteed
uniqueness.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
 
Back
Top