Dear Experts, Problem :
I need to save a datatable to a binary file , in binary format , in order to make the process fast because the datatable may contain up ten millions rows. So , XML is not favorable because it makes the file large sized , and the process will be slow.
I managed to save the datatable to a binary file , and it works fine , but the problem when I try to add new rows to the existing binary file (using a datatable with the same schema , but different rows data) , it copies the schema of the datatable to the binary file , making it very large. What is needed:
I need to be able to only add rows to the existing binary file. If you try the below code and run it 3 times , it should create the binary file and then add 5 rows for each save , ie , save 15 rows . But this is not the case. it will save table schema & 5 rows (in binary format) >>> then table schema & 5 rows (in binary format) >>>table schema & 5 rows (in binary format). Table schema itself is very large , and consumes much file size. I need to save the file schema only once , then the 15 rows. My Code: - Function GetTable() As DataTable
-
-
Dim table As New DataTable ' Create new DataTable instance.
-
-
table.Columns.Add("Dosage", GetType(Integer)) ' Create four typed columns in the DataTable.
-
table.Columns.Add("Drug", GetType(String))
-
table.Columns.Add("Patient", GetType(String))
-
table.Columns.Add("Date", GetType(DateTime))
-
' Add five rows with those columns filled in the DataTable.
-
table.Rows.Add(25, "Indocin", "David", DateTime.Now)
-
table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now)
-
table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now)
-
table.Rows.Add(21, "Combivent", "Janet", DateTime.Now)
-
table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now)
-
Return table
-
End Function
-
-
Private Sub SaveDataTabletoBinary()
-
dt = GetTable()
-
-
Dim format As New Binary.BinaryFormatter
-
Dim ds As New DataSet
-
' ds = DataGridView1.DataSource
-
-
Using fs As New FileStream("c:\sar1.txt", FileMode.Append)
-
dt.RemotingFormat = SerializationFormat.Binary
-
-
'Other option is SerilaizationFormat.XML
-
format.Serialize(fs, ds)
-
End Using
-
End Sub
-
Thanks
0 1349 Sign in to post your reply or Sign up for a free account.
Similar topics
by: REM |
last post by:
I have some problems. It's dilemma between BLOB, BFILE and takes care of
file on file system. What it's advantage??
I import some PDF document in BLOB filed in my database. It's about 1000...
|
by: Daniel Cardoso |
last post by:
I don't know what else to try - In my asp.net app, when the file name has
Windows-1252 characters (like ã and ç), these characters appear, each one,
as two strange characters in the file name label...
|
by: **Developer** |
last post by:
When I get the image from the file the file remains locked so the Delete
fails with a "used by another process"
So I tried using a clone and disposing the obtained image.
But that didn't fix...
|
by: KraftDiner |
last post by:
Hi!
In python I'm able to read in binary data from a file.
data = file.read() # Reads in an entire file.
However the data is 16bits per sample and python is storing the
data in a string. How...
|
by: suryanector |
last post by:
anybody knows source code for programs using Index file, inverted file operations, usage of B and B++ trees in C++ language plz send them.
|
by: abdoelmasry |
last post by:
hi
any one can help me plz ??
my code is about opening file as binary
then get data from file to edit
and rewrite data to file
this is the code:
#include <cstdlib>
#include <iostream>...
|
by: vunet.us |
last post by:
What is the workaround of passign a parameter to any included asp
file:
<!-- #Include File="file.asp" -->
This obviously does not work:
<!-- #Include File="file.asp?id=123" -->
Thank you
|
by: lalala |
last post by:
i need to retrieve the data stored in binary format from file into an array to make comparison.Can some1 write me a sample program ?? ermm something like below...
ifstream...
|
by: charlesbritto |
last post by:
A C++ program for counting individual string in a text file using file handling functions.,
for ex:
if the text file contains,
am a boy,am studying +2,am from chennai
Now the result shoud...
|
by: raylopez99 |
last post by:
I have the latest version of Visual Studio 2008 Professional, which
allows you to create resource files (this is the .resx file, no?),
unlike the Express version, which does not.
I am trying to...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| | |