MultiApplication with one DataBase-Synchronization between DB and Dataset

  • Thread starter Thread starter OstadAkbari
  • Start date Start date
O

OstadAkbari

I have a problem with Database and datasets in ADO.NET
I have 4 client Programs(Application) that each of them
first Fill a Dataset and then work with their's
dataset,each of them can update database using
DataAdapter update Method.
Now i want all programs use updated data in their dataset.
in other word, i want a way that i can update dataset in
application X when database was updated in application Y.

My way for solve this problem is:
Public MyDataset As DataSet

in determined priod of time occurs:

MyDataset = New DataSet("dsSoundPost")
daInBox.FillSchema(MyDataset,
SchemaType.Mapped)
daShahrVand.FillSchema(MyDataset,
SchemaType.Mapped)
daSound.FillSchema(MyDataset,
SchemaType.Mapped)

daInBox.Fill(MyDataset)
daShahrVand.Fill(MyDataset)
daSound.Fill(MyDataset)

If dataset not chande in one priod,in next priod it fills
and works properly,But
If dataset changes in one priod ,in next priod it's
structure will destroyed.
 
The quick dirty (but not necessarily what you want to do)
way is to use a timer or something to fire periodic
refreshes. This is ugly in many regards b/c you'll
requery the database and push updates when they may not
be needed. Even if you check for changes before firing
the update, you are still consuming network and database
resources. There are other methods but...

It's not an easy thing to do. There's not a way for
ADO.NET to know when something has changed in the DB it
came from until it goes back and checks. If you are
using SQL Server for instance, you could probably use
Notification Services to let you know of an update, but
even that would be difficult b/c let's say your DB has 20
million records and you push down records 0-10 million.
THen someone adds a record to the db or modifies record
20million. YOu may or may not care about the insert, but
almost certianly don't care about record 20million being
updated since nothing in ADO.NET is using it. Even if
you could use notification services , you'd need to
remember what was pushed down so you'd know what to
notify about. If you had Access or another db without
the functionality, this wouldn't even be an option.

I'd recommend using MSMQ and broadcasting updates to the
Queue that all apps could see. Have the client side apps
poll the que for changes, and requery when they happen.

So you have a trade off between complexity and
efficiency...but either you are going to notify the
other datasets that things have changed, or you'll have
to continually run refreshes irrespective of whether
things have changed or not.

I can't think of anything else.

Good Luck,

Bill

W.G. Ryan
(e-mail address removed)
www.knowdotnet.com
 
Back
Top