By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,850 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,850 IT Pros & Developers. It's quick & easy.

Export to flat file

P: n/a
Hi There,
I am developing an windows application using VB.NET and I need to export and
open the contents of my datagrid to a flat file. Preferably txt or wordpad.

Whats the best direction/chunk of code to do this?

Thanks,
Kevin.
Jan 3 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Kevin Humphreys" <kh********@hotmail.comwrote in
news:#v**************@TK2MSFTNGP04.phx.gbl:
I am developing an windows application using VB.NET and I need to
export and open the contents of my datagrid to a flat file. Preferably
txt or wordpad.

Whats the best direction/chunk of code to do this?
There is an open source library called "FileHelper" which can export to
CSV, Tab Delimited, etc.

SQL Server also supports file exporting... through DTS/SSIS.

--
sp**********@rogers.com (Do not e-mail)
Jan 4 '08 #2

P: n/a
Kevin,

Because you are talking about a DataGrid and not about a DataGridView, then
there is for sure a DataTable or DataSet as datasource.

The most simple is to save that as a XML file as

mydataset.WriteXML(path)

However you can as well loop through the tables and write a CSV or whatever.

Cor

Jan 5 '08 #3

P: n/a

"Kevin Humphreys" <kh********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi There,
I am developing an windows application using VB.NET and I need to export
and open the contents of my datagrid to a flat file. Preferably txt or
wordpad.

Whats the best direction/chunk of code to do this?

I don't know if this will put you in the ballpark. It just happens to be C#
and was in a Web solution. But it might give you a clue to get it to a file.
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
DataGrid1.RenderControl(hw);
Response.Write(sw.ToString());
Response.End();

Jan 5 '08 #4

P: n/a
There is an open source library called "FileHelper" which can export
to CSV, Tab Delimited, etc.
Can you provide a link please

tia
Wolf


Jan 5 '08 #5

P: n/a
Wolf Saenger <wo**********@web.dewrote in news:59706510ee38ca1db8b0cae190
@news.motzarella.org:
>There is an open source library called "FileHelper" which can export
to CSV, Tab Delimited, etc.

Can you provide a link please
http://filehelpers.sourceforge.net/
--
sp**********@rogers.com (Do not e-mail)
Jan 6 '08 #6

P: n/a

This discussion thread is closed

Replies have been disabled for this discussion.