473,549 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11195
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.Dat aTable implements ISerializable, so this is no big
challenge: the following example uses binary serialization

using System.Runtime. Serialization.F ormatters.Binar y;

[...]

//Create DataTable and Serialize
private void button1_Click(o bject sender, System.EventArg s 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(o bject sender, System.EventArg s 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
1693
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 thinking about is how to store messages on the hard disk and access them when needed. I dont want to read all the messages in at runtime because...
0
1039
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 client can last anywhere from a few seconds to maybe an hour. My question is, with all this data coming in what is the best way to write this...
0
1058
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 project involves automation of Word, Excel etc on the CLIENT side. I have binary data which is an EXE file stored inside an SQL Server Image...
12
3738
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 question is about storing data in a database. Yes I understand that you can link to a database in your program and read and write to the database etc...
13
4835
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 === question 1 Primarily Im trying to design a program that has full control over a hard disk. What it needs to do is find out what sectors...
3
6444
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 solved? can help me? thanks.
5
6734
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
3046
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
1959
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 something like this username_filename.In database i am storing file name,file size,file type.Some coading for this i am showing here ...
0
7518
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7446
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7715
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7808
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6040
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.