Get extern changes back into dataset without completely refill

G

Guest

Hello,

I have a (typed) dataset for some tables in a sql-server express.
Well, loading the datas with Fill and sending changes to the sql server with
Update works fine.

What I like to do is, sending the changes in the sql server (done by an
other instance of my application on a different pc) back into the dataset
WITHOUT having to fill the whole dataset again with the Fill-command.

My sollution at the time is, that every row has a timestamp value and I ceep
track of the highest timestamp value of any table. So I can fill with "WHERE
timestamp > oldtimestamp".

That works good, but what about deleted rows?
Saving them in a own table (cause my own application delets them, I can do
this), read that table and remove the deleted rows from dataset...

Well, since I'm shure, I'm not the only one wanting to do this, I hope,
there is a better, easier, elegant way doing this??

Hoping for help and new ideas,
Robert Witter
 
W

WenYuan Wang [MSFT]

Hi Robert,

According to your deception, I understand you have many instances of
application on different PCs. You would like to fill the tables which has
been updated by other instance rather than fill the whole dataset again.
Please let me know if I have misunderstood anything here. Thanks.

Timestamp is good solution for Update rows. However, it will meet issue on
Insert/Delete rows.
One way to resolve this issue, I suggest you may compare the number of rows
in database with the number of the rows in your dataset.( Select count(*)
from table). If your application deletes one row and adds a new row, the
number of rows doesn't change. But the new row will create a new timestamp.
According to your inital post, you will fill with "WHERE timestamp >
oldtimestamp", thus it's not the issue.

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

WenYuan Wang [MSFT]

Sorry,
According to your deception
It should be
According to your description, I understand...

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

Guest

Hi Wen,

yes, thats it exactly.

The idea with the count of rows is great! Thanks for that.
I think, thats the way I'll do it.

As I understood, I fill the dataset with "WHERE timestamp > oldtimetamp" and
compare the row counts after that. If the row count in the sql server is less
then the row count in the dataset I think, the only way is to clear the table
and fill it with the standard Fill command.
Or is there any way to avoid clearing the table?

Sincerely,
Robert Witter
 
W

WenYuan Wang [MSFT]

Hi Robert,
Thanks for your reply.

As you see, my idea is comparing the row counts and then clearing the
table, filling it again. I'm afraid it is difficult to check which row has
been deleted in database. However, if you really want to achieve this, I
think you may get current primary key list from database(select id from
table), and then compare it with your datatable in client machine to check
which row has been removed....

Sincerley,
Wen Yuan
Microsoft Online Community Support
 
G

Guest

Hi WenYuan,

Yes, I think so too, clearing the table is the easier way.

Thank you very much for your help!

Sincerley,
Robert Witter
 
W

WenYuan Wang [MSFT]

Hi Robert,

You are welcome.

Have a great day,
Sincerely,
Wen Yuan
Microsoft Online Community Support
 

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