469,601 Members | 2,039 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,601 developers. It's quick & easy.

write text file into dataset

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
1 9542
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.

Similar topics

2 posts views Thread by jason hirst | last post: by
reply views Thread by Dean Slindee | last post: by
4 posts views Thread by marcmc | last post: by
6 posts views Thread by Hans | last post: by
12 posts views Thread by =?Utf-8?B?Smlt?= | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.