Filling data from SQL

Hi friends,

In my  application, I use a DataTable called   "Objects" , I fill this table from a  data table called  "tblObjects"  which is in an SQL Server database.

There are other users can access to this database and can make changes on the table "tblObjects". 
Therefore everytime I work with the data table "Objects", I have to refill my "Objects" data table to ensure that i'm working with the current data.

But this proccess takes a long time, it slows down my application, it brings extra weight to the network and the Server. 

If I could check that if  the table  "tblObject" (from the server) is changed or not , I could avoid this extra weight.
If the table is not changed there is no point to refill the datatable right   :-)

Or if I can handle the changes on the table "tblObject" on the SQL Server  then  I could take an action.

I hope it is clear

Could you please give me some advises to implement this structure.

If some one can help me with this issue, I'll be very happy. Thanks a lot..

 

 

 

 

 

 

 




Answer this question

Filling data from SQL

  • Aleniko29139

    I have already did ;)

  • carp

    Thanks Jeff

    It seems to be a good soolution. I think i will implemet this sollution to my application.



  • jbm007

    This can't be done automagically, however this is what we have implemented to handle the same problem with our lookup tables (combo/dropdown data).

    1. Create a table (tblRefreshDates) that has the following Columns: TableName VARCHAR(20) and DateLastUpdated DATETIME.
    2. Enter tblObjects as the TableName and a date that reflects when the data was last changed.
    3. Either put a trigger on the table that you want to check and have the trigger update tblRefreshDates when changes are made to its contents, or have the code that makes changes to the table you want to check update tblRefreshDates
    4. Persist a copy of tblRefreshDates to the local HD (we use XML)
    5. When the application is run, pull the DateLastUpdated value for tblObjects from the persisted tblRefreshDates table and send it to the server
    6. Have the server check if the date sent by the client is older than the date stored in tblRefreshDates on the server. if so, return the new data to the client. If not, return nothing.
    7. Update the DateLastUpdated in the peristed XML if data was returned from the server

    This works really well for us.

    Cheers
    Jeff



  • R Raghu

    Glad to help.

    Could you please mark my answer as answering your question



  • Filling data from SQL