Re: SQL Query to csv file in C#

"Hewitt, Simon C. (Contractor)" <[email protected]> Fri, 25 May 2007 04:34:28 +0100
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <CF362B9DFA7D2544934516DFA1459AEC0147F5F9@BP1XEUEX709-C.bp1.ad.bp.com>
I don't think theres anything built-in for this so you'll have to roll
your own.

You could use a DataReader so that regardless of the total number of
rows to be written, there only be a few in memory at any one time.

Also look at http://www.codeproject.com/useritems/filehelpers.asp

Cheers
Simon


> -----Original Message-----
> From: Discussion relating to the specifics of the C# and=20
> Managed C++ languages [mailto:[email protected]]=20
> On Behalf Of Peter Osucha
> Sent: 25 May 2007 02:42
> To: [email protected]
> Subject: [DOTNET-CX] SQL Query to csv file in C#
>=20
> I had a handy method to take a query result (geez, I can't=20
> even remember
> what the object was called) and write it directly to a CSV=20
> file in VB6 (some
> of the queries I have to write have a lot of records and if I=20
> don't have to
> loop through them to write them to a file, I think things will be much
> faster).
>=20
> I have been searching for a similar sample in C# for Net 2.0=20
> and I'm not
> having much luck.  I was even hoping I might do it with a=20
> method that is
> part of one of the SQL data objects in NET.
>=20
> Any easy solution for this?
>=20
> Peter
>=20
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>=20
> View archives and manage your subscription(s) at=20
> http://discuss.develop.com
>=20

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
This list is hosted by DevelopMentor=AE  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com