473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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 '08 #1
1 1540
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! |
********************************************
<mr*****@gmail.comwrote in message
news:c6**********************************@d1g2000h sg.googlegroups.com...
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 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tim Pascoe | last post by:
I am using the Dynamic Cross-Tab code supplied in an article from SQL Server Magazine (http://www.winnetmag.com/SQLServer/Article/ArticleID/15608/15608.html). I modified the script to generate a...
0
by: Ex-Em-El | last post by:
I have a problem in creating a dynamic table in the same xml : 1.xml: <?xml version="1.0" standalone="yes"?> <?xml-stylesheet type="text/xsl" href="2.xsl"?> <aaa...
2
by: Sam | last post by:
Hello everyone, I have a table, which contains a picture column, I put URL info into it. "www.myweb.com/1.jpg..." I want to show this picture in my crystal report, I find some samples show the...
5
by: Krishnan | last post by:
Hi, Sorry if this is a cross-post. Wondering if there is any way to genrate Windows UI from an xml file just as one would load a Web UI as HTML from an XML using XSLT. Please do let me know if...
6
by: Trevor Hartman | last post by:
Hi, I need to refer to my objects dynamically. I have a 7 table cells (sunCell, monCell, tueCell....). I am looping through some data, checking its date and adding it to the correct cell. I...
1
by: sleigh | last post by:
Hello, I'm building a web application that will build a dynamic form based upon questions in a database. This form will have several different sections that consist of a panel containing one to...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
16
by: pukivruki | last post by:
hi, I wish to create a temporary table who's name is dynamic based on the argument. ALTER PROCEDURE . @PID1 VARCHAR(50), @PID2 VARCHAR(50), @TICKET VARCHAR(20)
3
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I think this question was discused quite often before. But maybe some "good-brain" has a great idea ... :-))) I have a DataSet with "unknown" columns. The CLR Function should work...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.