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

write text file into dataset

P: n/a
Hi,
I want to read a text file, and then write it into dataset. Is it possible?
or Is there any solution that read text file into DB?

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>x/Vs9+Nw2U6Px6tC6dj55w==</Id>
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi WebSim,

Just store the text file as a byte[].

DataSet set = new DataSet();
set.Tables.Add(new DataTable());
set.Tables[0].Columns.Add(new DataColumn("col", typeof(byte[])));

FileStream fs = File.OpenRead("any.file");
byte[] b = new byte[fs.Length];
fs.Read(b, 0, (int)fs.Length);
fs.Close();

DataRow dr = set.Tables[0].NewRow();
dr[0] = b;
set.Tables[0].Rows.Add(dr);
--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.