473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Storing datatable data in hard disk

VMI
Is it possible to store the data in a datatable in the hard disk instead of
the memory? By default, when a datatable's being filled, the table (and
data) will remain in memory. Would it be possible to save this data in
another medium besides the memory? Everything would stay the same but
instead of filling up the datatable by storing it in the memory, i'd be
storing it somewhere in the hard drive.

Thanks.
Nov 16 '05 #1
1 11155
VMI wrote:
Is it possible to store the data in a datatable in the hard disk instead of
the memory? By default, when a datatable's being filled, the table (and
data) will remain in memory. Would it be possible to save this data in
another medium besides the memory? Everything would stay the same but
instead of filling up the datatable by storing it in the memory, i'd be
storing it somewhere in the hard drive.


System.Data.DataTable implements ISerializable, so this is no big
challenge: the following example uses binary serialization

using System.Runtime.Serialization.Formatters.Binary;

[...]

//Create DataTable and Serialize
private void button1_Click(object sender, System.EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("uid");
dt.Columns.Add("test");
for (int i = 0; i < 10; i++)
{
DataRow dr = dt.NewRow();
dr[0] = i;
dr[1] = string.Format("test{0}", i);
dt.Rows.Add(dr);
}

FileStream fs = new FileStream(@"C:\test.bin", FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, dt);
fs.Close();
}
//Deserialize DataTable from File
private void button2_Click(object sender, System.EventArgs e)
{
FileStream fs = new FileStream(@"C:\test.bin", FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
DataTable dt = (DataTable) bf.Deserialize(fs);
fs.Close();
foreach (DataRow dr in dt.Rows)
{
Debug.WriteLine(dr[0].ToString());
}
}

There are also possibilities to serialize data to XML/SOAP, have a look
at the documentation:

http://msdn.microsoft.com/library/en...ingObjects.asp

Cheers

Arne Janning
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Simon Harvey | last post by:
Hi everyone, I'm hoping for a little bit of advice on the following. I am in the process of making a small application that can send, receive and store email messages. The current area that I am...
0
by: Mike | last post by:
Hi All, I'm writing an application that is accepting data from possibly 100's of clients. The amount of data I get is around 3 or 4 KB per second per client. The data that is streamed from the...
0
by: Michael Bredbury | last post by:
I am developing using Visual Studio .NET 2002 using ASP.NET and VB.NET. This is a web-based project which needs to install various ActiveX components on the users PC. ActiveX is needed because the...
12
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My...
13
by: ragtag99 | last post by:
I posted this on comp.lang.asm.x86, alt.os.development, comp.arch, comp.lang.c++ Im working with windows xp professional, NTFS and programming with MASM, c++ (free compiler) or visual basic 6.0...
3
by: ary | last post by:
I try to create a weblog host site! in this case i can't use cache for every page because that cause to be my Server ram full of caching page. but if I can save cache in hard disk my problem...
5
by: GUNDALA GIRIBABU | last post by:
How To Find All Video Files Including Hidden Files.students Are Storing Erotic Contents In The Hard Disk. I Want To Remove These Files From Hard Disk I Am Using Xp
11
by: GG | last post by:
Anybody knows of any collection where is not stored in memory but using hard disk instead? Thanks *** Sent via Developersdex http://www.developersdex.com ***
1
by: itsmenarwal | last post by:
I have made a application form in which i am asking for username,password,email id and user's resume.Now after uploading resume i am storing it into hard disk into htdocs/uploadedfiles/..in a format...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.