Changing values for unbound columns in a typed dataset

N

nagar

My application connects to a SQLite db and gets a number of fields
which are displayed in a list though a typed dataset.

I need to manually update an unbound column (which contains the index
of the picture, which is not stored in the DB) whose content is
decided by my application logic.

I've tried cycling though the rows

foreach (DatasetCommands.CommandsRow r in dsCommands.Commands.Rows)
r.ImageIndex = 1;

but the line that that actually sets the data is very slot. It takes
more than 30 seconds for updating about 4000 rows.

What's the proper way to do it?
Thanks.
Andrea
 
W

WenYuan Wang [MSFT]

Hello Andrea,

As far as I know, there is no Microsoft driver for SQLite DB. I've never
heard of "DatasetCommand.CommandsRow" either. It seems you are using 3rd
party library to connect to SQLite DB, correct? If I misunderstood anything
here, please don't hesitate to correct me.

If this is the case, 3rd party library is not supported by Micrsoft. I
suggest you may post this issue in some forums which is related to such 3rd
party library, because the people in those groups will be more likely to be
able to help and familiar with such product.

If you have any more concern, please feel free to update here. We are glad
to assist you. thanks.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
N

nagar

Thanks,

yes I'm using a third party library and the objects I mentioned are my
own. As far as I know, if I'm working with a typed dataset, it
shouldn't matter which database I'm using. Is that right?

I've noticed that iterating on the rows of a typed dataset and
changing the value of the data is very slow.

If I want to update manually 4000 rows, is it feasible to iterate on
the collection or should I use another method?
thanks.
Andrea
 
W

WenYuan Wang [MSFT]

Hello Andrea,
Thanks for your reply.

Now, I understood you are working with a Typed Dataset which connects to
SQLite DB by 3rd provider. DatasetCommands.CommandsRow is written by
yourself, correct? If I misunderstood anything here again, please don't
hesitate to correct me.

I'm not sure how you implement the DatasetCommands.CommandsRow class. But,
iterating on the tableRows collection is the correct way in your case. It
should not take so long time to update 4000 rows. In following code
snippet, I created a TypedDataset instance, filled data into it by
TableAdapter, and updated the C2 column in table by iterating on
collection. Finally, I updated the change into Database by Table Adapter
again. I added stop watch into code to trace how much time is used on each
line of code. It takes me 136 milliseconds to update 4000 rows in cached
datatable, and 5917 milliseconds to update the change into SQL Database.

DataSet1 ds = new DataSet1();
DataSet1TableAdapters.Table_1TableAdapter tt = new
WebApplication29.DataSet1TableAdapters.Table_1TableAdapter();
tt.Fill(ds.Table_1);

System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Start();
foreach (DataSet1.Table_1Row tr in ds.Table_1.Rows)
{tr.c2 = "100";}
watch.Stop();
Console.WriteLine("#1 UpdateTable Elapsed milliseconds {0}",
watch.ElapsedMilliseconds);

watch.Reset();
watch.Start();
tt.Update(ds.Table_1);
watch.Stop();
Console.WriteLine("#2 UpdateDatabase Elapsed milliseconds {0}",
watch.ElapsedMilliseconds);

//#1 UpdateTable Elapsed milliseconds 136
//#2 UpdateDatabase Elapsed milliseconds 5917

We highly recommend you add the stopwatch to check which line takes 30
second in your application.

Hope this helps,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

WenYuan Wang [MSFT]

Hello Andrea,

Had you have chance to try my suggestion so far? Do you face any further
issue?
Please feel free to update here again, if there is anything we can help
with. We are glad to assist you.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
N

nagar

Thanks for your help. I managed to solve the problem which had to do
with the actual dataset structure.
 
W

WenYuan Wang [MSFT]

Hello Andrea,

You're welcome. It's my pleasure to assist you.
If there is anything we can help with on this issue, just feel free to
update here again. We are standing by. :)

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Top