473,591 Members | 2,919 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 11210
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
1697
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 that would make startup take to long. What I think I need to do is to load a 'header' file at...
0
1041
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 information to disk. At the moment I am simply storing up the data in a memory buffer and when the...
0
1061
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 table which I need to pass to the clients browser and create the original EXE file on their hard disk....
12
3745
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 etc. Well, that's all find and dandy but what if the person you're writing the application for...
13
4844
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 haven't been
3
6447
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
6736
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
3053
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
1961
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 $filesize=$_FILES; $filename=$_FILES; $filetype=$_FILES; $temp_name=$_FILES; //temporary name of uploaded...
0
7935
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 usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
7871
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7995
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5400
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3851
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2379
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
1467
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1202
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.