473,386 Members | 1,773 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,386 software developers and data experts.

DataTable Bizarreness

I have this giant table in our database that represents a dumping ground for
file imports. It's 44 columns wide and nominally about 30 million records,
indexed in blocks by the file the records came from.

I also have this incredibly elaborate class library that cleans the data in
various columns (you would not believe the trash that comes in on the
PhoneNumber field)

One of the things that has been bugging me for a long time is this issue
here:

In my cleaner app, I have dozens of methods that do really heavy string
manipulation that all pretty much go like this:

1. Get a DataTable from the raw-data dumping-ground table via a
SqlDataAdapter
2. Loop over the Rows collection cleaning the values based on business rules
3. Put the values into the actual entity tables where they belong, via a
SqlDataAdapter

But here's the whammy:

Since the DataTable was populated from a DataAdapter, the DataRows all think
they came from the database, and rightly so. But after my cleaning
algorithms, the cleaned values represents INSERTs to their respective
tables. But when I say da.Update(dt), the DataAdapter sees a DataTable with
*modified* values, not *new* values, and instinctively runs its
UpdateCommand. But I'm not doing updates, I'm doing inserts. So I keep
finding myself having to LIE to the DataAdapter by putting a stored
procedure that does INSERTs into the DataAdapter's UpdateCommand.

It works, but I don't like it. It seems like a perverse filthy hack.

Anyone have a better idea?

--
Peace & happy computing,

Mike Labosh, MCSD

"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"
Nov 21 '05 #1
4 959
Hi,

Sounds like you need to merge the records into the other table.
http://www.windowsformsdatagridhelp.info/default.aspx

Ken
--------------
"Mike Labosh" <ml*****@hotmail.com> wrote in message
news:uV*************@TK2MSFTNGP12.phx.gbl...
I have this giant table in our database that represents a dumping ground for
file imports. It's 44 columns wide and nominally about 30 million records,
indexed in blocks by the file the records came from.

I also have this incredibly elaborate class library that cleans the data in
various columns (you would not believe the trash that comes in on the
PhoneNumber field)

One of the things that has been bugging me for a long time is this issue
here:

In my cleaner app, I have dozens of methods that do really heavy string
manipulation that all pretty much go like this:

1. Get a DataTable from the raw-data dumping-ground table via a
SqlDataAdapter
2. Loop over the Rows collection cleaning the values based on business rules
3. Put the values into the actual entity tables where they belong, via a
SqlDataAdapter

But here's the whammy:

Since the DataTable was populated from a DataAdapter, the DataRows all think
they came from the database, and rightly so. But after my cleaning
algorithms, the cleaned values represents INSERTs to their respective
tables. But when I say da.Update(dt), the DataAdapter sees a DataTable with
*modified* values, not *new* values, and instinctively runs its
UpdateCommand. But I'm not doing updates, I'm doing inserts. So I keep
finding myself having to LIE to the DataAdapter by putting a stored
procedure that does INSERTs into the DataAdapter's UpdateCommand.

It works, but I don't like it. It seems like a perverse filthy hack.

Anyone have a better idea?

--
Peace & happy computing,

Mike Labosh, MCSD

"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"

Nov 21 '05 #2
Mike,

Reading this I get first the idea, why is Mike using a datatable and not
just a datareader and process all rows one by one and insert/update them
with a command.nonquery.

It will be at least faster.

Cor
Nov 21 '05 #3
> Reading this I get first the idea, why is Mike using a datatable and not
just a datareader and process all rows one by one and insert/update them
with a command.nonquery.


Because mikey doesn't like holding onto the server while chewing on several
hundred thousand string manipulations. I prefer to select the stuff, chew
on in and then batch-update it.

We don't do any OLTP stuff here at all. We're a batch-shop. Every single
thing we do here is a giant heap of several hundred thousand rows. Doing
little transactions here would just fill the network with peanut butter.
--
Peace & happy computing,

Mike Labosh, MCSD

"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS."
-- General Barringer, "War Games"
Nov 21 '05 #4
Mike,

Because mikey doesn't like holding onto the server while chewing on
several hundred thousand string manipulations. I prefer to select the
stuff, chew on in and then batch-update it.

Using a dataadapter or whatever does give you at least the same amount of
network traffic as a datareader and a command.execute non query.

Those are both used by the dataadapter.

The only effect will probably be that with an Ethernet network, using the
way I told, probably you will have less collisions (and with that a higher
performance), because you are now giving all the data in one large batch,
what is forever bad for this kind of LAN's.

I hope this helps,

Cor
Nov 21 '05 #5

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

Similar topics

5
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the...
5
by: Stefan Turalski \(stic\) | last post by:
Hi, I'm wondering if there is a way to send a method parametrs by ref when DataTabel is a type of this value ? I done some sort of select over DataTable columns, just by removing them froma...
2
by: Newbie | last post by:
Im getting an exception: System.FormatException: Input string was not in a correct format. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at...
1
by: TaeHo Yoo | last post by:
Hi all, After sorting and grouping data using a dataview, then how to transfer the changed datatable in the dataview to a datatable in C#? Cheers
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
7
by: Raymond Lewallen | last post by:
Which would be the proper way or the reason for using any of the following or combinations of the following? These are the 3 ways I've figured I can do what I want to do, I just don't know which...
3
by: Gene Hubert | last post by:
I'm using DataTable.ImportRow to move data from one datatable to another... Dim dt, dtTarget As DataTable Dim dr As DataRow dt = DirectCast(Me.DataSource, DataTable) dtTarget = dt.Clone...
0
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: ...
5
by: Frank Hauptlorenz | last post by:
Hello, I recognized some days ago, that returning a DataTable blocks my WCF-Service. Is this a known bug? If I add this table to a new DataSet() and return this, it works. Thank you, Frank
0
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,...
0
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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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,...

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.