Datasets - Cloning problems

G

Guest

Hi,

I have 3 datasets
d1Main is the main dataset having rows.
I loop through rows in d1main and any row failing validations is moved to
d2Bad dataset. I had to clone d2bad as d1main and then add failed row to
d2bad

so d2bad is created out of d1main.

Now comes d3good. any records valid in d1main are moved to d3good. again
this was done by cloning d1main for d3good.

Now i use d3good to update the database. The moment database error occurs. I
have to move row in d3good to d2bad.

Moving is failing as it says row already exists. Already d3good is cloned
out of d1main. I cannot clone it again out of d2bad.

how do I do this??
 
S

sloan

I wouldn't clone.

I'd do this


mydataset dsAllData = new mydataset();



mydataset dsPotentiallyGoodDS = new mydataset();


mydataset dsBadData = new mydataset();


Loop over dsAllData

when an error occurs then do this

for each alldatarow in dsAllData.Select("");

mydataset.mytable.myrow badrow = dsBadData.mytable.Newmyrow();
badrow.a = alldatarow.a;
//continue on all properties

dsBadData.mytable.Addmyrow( badrow );

next alldatarow

something like that.. the syntax will be wrong.

The key is..... add a NEW row to the bad dataset or potentiallGood dataset
as you encounter them.


...
 
G

Guest

I wanted to avoid setting value of each column.
And so had to clone and Import.
Columns are not defined. The main dataset could have different kind of data.
Not the same columns always.

To be more precise, I load the dataset from client files. Processing is same
for different files. But the columns in the files could be different.
 
S

sirfunusa

Don't do that. Use T-SQL in a stored proc for everything. Load the
client files to a temp table, and process on the server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top