How to copy a complex query result into a csv in file system  
Author Message
rajeshbhaskaran





PostPosted: .NET Framework Data Access and Storage, How to copy a complex query result into a csv in file system Top

hi

How to copy a complex query result into a csv in file system

Regards

Rajesh



.NET Development16  
 
 
CetinBasoz





PostPosted: .NET Framework Data Access and Storage, How to copy a complex query result into a csv in file system Top

You didn't give much details. A way would be:

-Create a text file with csv extension.

-ExecuteReader()

-Write column names on first line separated by commas

while ( reader.Read() )

{

// Write row data, fields separated by commas and " as string delimiter. Each row ends with a CRLF pair

}


 
 
VMazur





PostPosted: .NET Framework Data Access and Storage, How to copy a complex query result into a csv in file system Top

It depends on source of the data. In a case of SQL Server, you could write SQL DTS job that does it for you. If you have data in a DataSet, then you could use method described in CetinBasoz post or transform DataSet's XML into CSV using XSL