DataRow hashCode or fingerprint...

  • Thread starter Ing. Davide Piras
  • Start date
I

Ing. Davide Piras

Hi there, I really don't know if I can post here or
microsoft.public.dotnet.framework.adonet could be better... anyway:

in my .NET 2.0 C# arcitecture (windows form as client application, web
application/web services as server), I have some methods that retrieve
datasets from web service, then i save them locally with WriteXML and I can
work offline, making insert, update and delete... then I connect again and I
send only the changed rows to the web service that saves them to the
database.

Then any client has to get the new data as well in order to reflect the
latest database status, and here is the problem, I'm getting always all the
datatable because I don't know in which way I can recognize new or updated
rows.

I was thinking about getting an hashcode of any single row but I don't know
in which way I can do this, then I've to send all the hashcodes to the
webservice and it will give me back only the rows where the hashcode doesn't
match... but having thousand of rows is too eavy to send via web services
all the hashcodes then is heavy on the server to compute the hash and
compare one by one....

So I thought I can add a new column to any involved table on the database
and define a trigger on insert and on update and save the latest
update/insert date... then I can save on the client the last download date
and the time after I can get only the rows inserted/updated after last
download... is it good? there should be no problem making those triggers and
if any table I need to downlaod hash that column, then I can fill a dataset
on the server in this way:

SELECT * FROM TABLE WHERE LASTUPDATE > ?LASTDOWNLOADDATE

Currently we use mysql as server engine but we need to keep our project open
to exhange the db server later... (actually the server datalayer is loaded
at runtime depending on the wb.config and implement a IDataLayer interface
that make it easier to implement a SQLServer DataLayer or even an
AccessDataLayer...)

Any Idea ? Can I use triggers in this way? Tha datatable are now full of
data and downloading all tables with all records is safe but takes long time
(more than 10.000 record in total)... and I'm downloading data page by page
calling the webmethod, so actually I don't need any DataSetSurrogate or
anything else... since I download large tables by pages of 100 or 400
records (it's a client program option).

How can I solve the problem and avoid to download again everything everyday?

Thanks, Regards, Davide.
 
N

Nicholas Paldino [.NET/C# MVP]

I would use the trigger to place the date in the row. You could save
some time by having your data layer insert the date for you when the record
is saved (and not need the trigger).

Also, if your database supports it, you could use a timestamp column (I
believe SQL Server and Oracle support this in some form or another) to
determine if the version of the row in the db is the same as what you are
trying to save.

Hope this helps.
 

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