473,322 Members | 1,494 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,322 software developers and data experts.

Write to CSV

Hi all,

I need some help on how to generate and write a CSV file in my ASP app
(i'm using c#). Ideally I'd like to generate the CSV file from the DB
and then offer it for download to the user, but i'm unsure where I
should start.

Any help would be appreciated.

Jun 12 '06 #1
4 1268
You could open a file to a predefined location with a random name,
write the db contents there and submit a link to the user.

To write to a file you can use a snippet similar to :

StreamWriter writer = new StreamWriter(File.Create('tempFileName'));
while (rdr.read()) {
writer.WriteLine('data');
}
writer.close();

and then send a link pointing to the file you 've created.

An alternative would be to create a HttpModule that could respond to a
specfic URL and output text/csv content, or a file with as an
attachment.

Regards,
Tasos
^MisterJingo^ wrote:
Hi all,

I need some help on how to generate and write a CSV file in my ASP app
(i'm using c#). Ideally I'd like to generate the CSV file from the DB
and then offer it for download to the user, but i'm unsure where I
should start.

Any help would be appreciated.


Jun 12 '06 #2
See if this helps..

http://www.netomatix.com/GridExportToCSV.aspx

"^MisterJingo^" <mi*********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi all,

I need some help on how to generate and write a CSV file in my ASP app
(i'm using c#). Ideally I'd like to generate the CSV file from the DB
and then offer it for download to the user, but i'm unsure where I
should start.

Any help would be appreciated.

Jun 12 '06 #3
Hi all, I got it working but when I try and import the vcs file into
outlook I get the following error:

"This error can appear if you have attempted to save a recurring
Lunar appointment in iCalendar format.
To avoid this error, set the appointment option to Gregorian instead of
Lunar."

An example vcs file I generate can be seen below:

BEGIN:VCALENDAR
PRODID:-//IntraMed//NONSGML v1.0//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART:20060619T090000Z
DTEND:20060619T170000Z
SUMMARY: CPD Course Course 1
DESCRIPTION:test test test
CLASS:PUBLIC
END:VEVENT
BEGIN:VEVENT
DTSTART:20060614T090000Z
DTEND:20060614T170000Z
SUMMARY: CPD Course test 3
DESCRIPTION:test test test
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR

If I change the version to 1.0 I can import, but it only imports the
first vevent of the file and ignores the rest. Any ideas what I'm
doing wrong or how I can correct this error?

Thanks.
PS The title is wrong, it should read writing to a vcs file!

Jun 13 '06 #4
^MisterJingo^ wrote:
Hi all, I got it working but when I try and import the vcs file into
outlook I get the following error:

"This error can appear if you have attempted to save a recurring
Lunar appointment in iCalendar format.
To avoid this error, set the appointment option to Gregorian instead of
Lunar."

An example vcs file I generate can be seen below:

BEGIN:VCALENDAR
PRODID:-//IntraMed//NONSGML v1.0//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART:20060619T090000Z
DTEND:20060619T170000Z
SUMMARY: CPD Course Course 1
DESCRIPTION:test test test
CLASS:PUBLIC
END:VEVENT
BEGIN:VEVENT
DTSTART:20060614T090000Z
DTEND:20060614T170000Z
SUMMARY: CPD Course test 3
DESCRIPTION:test test test
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR

If I change the version to 1.0 I can import, but it only imports the
first vevent of the file and ignores the rest. Any ideas what I'm
doing wrong or how I can correct this error?

Thanks.
PS The title is wrong, it should read writing to a vcs file!


I've sorted this out, but i'll post what I've found here for anyone
else might come across this problem. It seems that to import multiple
vevents you have to use the import feature of outlook, just opening the
file imports the last event only. Also, outlook seems to need a unique
field called: UID:<unique hex num> to import the file correctly (add
this field removed the above error).

Jun 13 '06 #5

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

Similar topics

10
by: Greg Hurlman | last post by:
I've got what I'm sure is a very simple problem. In an ASP page, I am trying to write out 4 fields from a recordset in succession: Response.Write rs("LastName") Response.Write rs("Suffix")...
1
by: techy techno | last post by:
Hii Just wanted to know how can I decorate my texboxes and Listmenu which is called from a JS file using the following code below: document.write("<SELECT NAME='cur2' ONCHANGE='cconv1();'>");...
2
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
0
by: hari krishna | last post by:
hi all, My requirement is to generate xl reports throu Asp.Net without installing xl on web server computer. i am using Response object and wrtifile method as below. i dont know whether it is...
8
by: Ben | last post by:
Hi all, Just wondering how to write (using document.write) to a table cell. I have table with 3 rows and 3 colums. I want to write from within the Javascript to say third column of a first row....
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
11
by: Vmusic | last post by:
Hi, I am trying to write out an array of string variables to Notepad. I can't get SendKeys to accept the string variable only literal quoted strings. I DO NOT want the hassle of writing to a...
4
by: cbtechlists | last post by:
I have an ASP app that we've moved from a Windows 2000 to a Windows 2003 server (sql server 2000 to sql server 2005). The job runs fine on the old servers. Part of the app takes a recordset and...
0
by: kuguy | last post by:
Hi all, I'm new to the forums, so I hope this isn't in the wrong place... I have that "Software caused connection abort: socket write error" exception error that i've never meet before. ...
8
by: Mateusz Viste | last post by:
Hi, I am trying make some multimedia files playable from my website. So far, I am able to generate dynamically a new page containing the right <embed> section. However, when I load my script, it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.