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

Discussion in 'ASP .Net' started by mrflynn@gmail.com, Jul 8, 2008.

  1. Guest

    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
     
    , Jul 8, 2008
    #1
    1. Advertising

  2. 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! |
    ********************************************
    <> wrote in message
    news:...
    > 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
     
    Cowboy \(Gregory A. Beamer\), Jul 8, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page