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

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
 
C

Cowboy \(Gregory A. Beamer\)

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.
 

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

Members online

Forum statistics

Threads
474,039
Messages
2,570,376
Members
47,031
Latest member
AndreBucki

Latest Threads

Top