-
June 28th, 2009, 10:22 AM
#1
Refresh Database
i have a problem and it's hard to explain but don't know the solution for many years,pls help me...
A is viewing database from datagrid.
after that
B inserting a new data to database from different computer.
A still looking datagrid from database before updated.
if he don't click refresh or using timer how can the datagrid automatically refresh the data from database without using button or timer.
i don't like using timer cause it eat resources a lot.
thx
sorry bad english
-
June 28th, 2009, 05:34 PM
#2
Re: Refresh Database
User B cannot EDIT a record in that table, because it cannot get a LOCK without refreshing first.
-
June 28th, 2009, 07:25 PM
#3
Re: Refresh Database
That depends on the connection methods, it is totally possible for user A to be viewing data in a grid and user B edit the data or insert a record on a different machine. User A will not see the edit or insert until a refresh is done at user A's location.
A timer is the best solution I can think of, if used right a timer takes very little resources
-
June 29th, 2009, 08:06 AM
#4
Re: Refresh Database
i am afraid timer can make problem too.
example :
a grid display 100 row with vertical scroll. the user is looking at row 90
because i am using timer the grid is refreshing every interval 1 second ( i make 1 second timer refresh) so the scroll is always at top position.it make user hard to see the grid
is there any solution?
User B cannot EDIT a record in that table, because it cannot get a LOCK without refreshing first.
sorry i don't really understand it,do u mean i must lock the database if anyone see the grid
thx
-
June 29th, 2009, 08:23 AM
#5
Re: Refresh Database
I would not recommend actually refreshing the data every second but rather create a routine to see if the data has changed. I am not sure if there is a method in dot net for this or not but I am sure there is a way especially if the other user is using your program as well.
I have a program that does refresh the data in a timer routine written in vb6. The way I got around the display issues was by using a second grid. When I refresh I refresh the second [invisible] grid, move the record pointer and then display the second grid and hide the first. This prevents screen flicker and speeds up the process of populating the grid as well. Works good in this case but the data being used is not usually more than a couple of hundred records.
.
-
June 29th, 2009, 08:40 AM
#6
Re: Refresh Database
Originally Posted by DataMiser
I would not recommend actually refreshing the data every second but rather create a routine to see if the data has changed. I am not sure if there is a method in dot net for this or not but I am sure there is a way especially if the other user is using your program as well.
I have a program that does refresh the data in a timer routine written in vb6. The way I got around the display issues was by using a second grid. When I refresh I refresh the second [invisible] grid, move the record pointer and then display the second grid and hide the first. This prevents screen flicker and speeds up the process of populating the grid as well. Works good in this case but the data being used is not usually more than a couple of hundred records.
.
i think that's not really effective ways cause my data is more than hundred records.
i heard about using threading but i don't really understand how to use it
-
June 29th, 2009, 07:05 PM
#7
Re: Refresh Database
If you let the DB LOCK the record, then user B can't edit it. Please wait...
-
June 29th, 2009, 07:10 PM
#8
Re: Refresh Database
Originally Posted by RusdyRIP
i think that's not really effective ways cause my data is more than hundred records.
i heard about using threading but i don't really understand how to use it
I understand, and as I said it is probably not a good idea to refresh in a timer every n miliseconds but rather place some code in a timer to see if the data has changed and only when this is true do a refresh. This should nto be an issue other than the fact you will need to determine if the data has changed.
Of course you could lock the database and not allow anyone to edit it but in most cases that is not much of an option.
-
June 29th, 2009, 07:12 PM
#9
Re: Refresh Database
Originally Posted by dglienna
If you let the DB LOCK the record, then user B can't edit it. Please wait...
Note in the OP he was refering to another user inserting a record so locking the record you are viewing would have no effect.
-
June 29th, 2009, 07:32 PM
#10
Re: Refresh Database
Originally Posted by DataMiser
Note in the OP he was refering to another user inserting a record so locking the record you are viewing would have no effect.
yes,i think same too.if 2 user editing same record then it will have effect,but the problem is on grid report,thx
if i make a routine that check any changes on database,
i am afraid the server CPU Usage will raise,
if i make the routine then it will gonna check every second,if it have changes then it will refresh.
but if it don't have changes then it will gonna check to server.
if just one user i think it don't really will raise the cpu usage on server,but how about
if there is 5 user connecting and see the grid on 5 cpu,or every cpu open 5 report grid.
i think it will raise the cpu usage on server and can make the server crash.
thx
sorry bad english
-
June 29th, 2009, 08:22 PM
#11
Re: Refresh Database
Just LOCK the table when it EDIT mode, and you won't have a problem.
-
June 30th, 2009, 12:19 AM
#12
Re: Refresh Database
I didn't see a mention of which database you're using, but if you are using for MS SQL Server 2005 or later, you have access to the SQLDependency which can notify clients when changes occur in the database.
I'd suspect other databases might have similar technologies.
But this way you can set up a dependency to the data being viewed, and when they change the notification will fire an event and you can then refresh the data for the other viewers based on the edit.
-
June 30th, 2009, 01:14 AM
#13
Re: Refresh Database
Originally Posted by dglienna
Just LOCK the table when it EDIT mode, and you won't have a problem.
I do not understand how this could relate to the issue of wanting to refresh the view on the pc which is viewing the data that may have been added to or edited at another location? It the other pc locks the data for edit that is fine but that does not refresh the views on other pcs.
-
June 30th, 2009, 01:19 AM
#14
Re: Refresh Database
Originally Posted by RusdyRIP
yes,i think same too.if 2 user editing same record then it will have effect,but the problem is on grid report,thx
if i make a routine that check any changes on database,
i am afraid the server CPU Usage will raise,
if i make the routine then it will gonna check every second,if it have changes then it will refresh.
but if it don't have changes then it will gonna check to server.
if just one user i think it don't really will raise the cpu usage on server,but how about
if there is 5 user connecting and see the grid on 5 cpu,or every cpu open 5 report grid.
i think it will raise the cpu usage on server and can make the server crash.
thx
sorry bad english
Not sure what you are thinking here, no need for 5 grids.
-
June 30th, 2009, 06:16 AM
#15
Re: Refresh Database
Originally Posted by DataMiser
Not sure what you are thinking here, no need for 5 grids.
sory, i mean like this
i have application which using tab pages.
so user can show like 5 report/grid report.
if i use the check database method then i think the server will overload cause
the timer always send check routine and the 5 tab pages opened by user also make 5 timer and 5 check routine.
it will make server cpu usage rise.
thx
@Alsvha
i am using firebird database.may i know what the "name" of that dependancy.
so i can search the feature of the database.cause i think it will work
thx
@dglienna
i think i have same opinion like DataMiser,i don't really think it related
thx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|