Read changed data

bufer24

Active member
Joined
Mar 27, 2008
Messages
35
Programming Experience
3-5
Hello, I am currently testing my small SQL database application. The database is stored on the server on a local PC. The client application can run on local PC or there can be several clients on remote computers. I´ve put a timer in my client app to ensure refreshing of data every 20 seconds. It works fine except for this case: for example there are 2 clients running on different PC´s. Both clients see the same records. When 1 client adds a record the second client can see it when it refreshes. But when I delete a record, the other client still holds the original data even after refresh. I use this code to refresh (re-read) data:

Conn.Open()
MyAdapter=New SQLDataAdapter("SELECT * FROM MyTable", Conn)
MyAdapter.Fill(DS, "MyTable")
Conn.Close()

DS is the dataset. It has the same structure as the database. Conn is the SQLConnection. How to go around this problem?

Thanks
 
Sounds like the client that performed the delete didn't commit the transaction it was in, or didnt send the delete to the database at all
 
Agreed, my first guess is the delete didnt fully go through.

Also it looks like your constantly doing a new fill (appending new records) to the same dataset table without first clearing the existing data.
 
Also it looks like your constantly doing a new fill (appending new records) to the same dataset table without first clearing the existing data.

Possibly, though we don't see the dataset declaration so its scope is not truly known
 
Tom, you were right. The records count is only rising but never declining. So I simply placed:

DS.Tables(0).Rows.Clear

before the fill and it works great now. Many thanks ;)
 
Back
Top