Results 1 to 3 of 3

Thread: Compare Remote and Local Database table feilds

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2014
    Location
    Northampton, UK
    Posts
    59

    Question Compare Remote and Local Database table feilds

    Hi Everyone,

    I hope someone can help me out here

    I have a central Database (called SvrData) and I also have a local version of the database (called PoSDB) i have a sync app (that runs headless) that I have created to sync the data from the Local database to the server and to sync all Data from the Server to the local database.

    This works fine but what I would like to do is compare data from the table called products (field Called lasteditedon) to see if the last edit date has changed if it has to run a update commands


    The lasteditedon field is stored like this yyyy/mm/dd so what i want to know is how do i use VB to compare the Data that is stored in my Local database with what is stored in the Server database (the Server database MUST be the Master database)

    I do not want to use Replication as some of the Local Computers can not run MySQL very quickly so I am using Firebird on them (but they still support SQL queries)

    i was thinking something like this

    count the number of records that have changed
    Retrieve the changed Records from the server
    Update local Records


    Does anyone have any vb code that they could share with me to show me how to work this out (or even to give me a heads up)


    The Server is connecton is delcared like this
    Code:
    Public DBConn As MySqlConnection
    and the Local database is declared like this
    Code:
    Public fbDBConn As FbConnection
    I hope this helps.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Compare Remote and Local Database table feilds

    Quote Originally Posted by AndyGable View Post
    The lasteditedon field is stored like this yyyy/mm/dd
    Does that mean that it's stored as text? If so, that is your first mistake. That format should actually work, because alphabetical order would match chronological order, but you should still be storing dates as binary dates, not text. If it is stored as binary dates then it's not sto9red the way you showed, because format is just a display issue, not a storage issue.

    If you want to update database A with any changed records from database B, you simply query database A for the latest change date and then query database B to get all records with a change date later than that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2014
    Location
    Northampton, UK
    Posts
    59

    Re: Compare Remote and Local Database table feilds

    Quote Originally Posted by jmcilhinney View Post
    Does that mean that it's stored as text? If so, that is your first mistake. That format should actually work, because alphabetical order would match chronological order, but you should still be storing dates as binary dates, not text. If it is stored as binary dates then it's not sto9red the way you showed, because format is just a display issue, not a storage issue.

    If you want to update database A with any changed records from database B, you simply query database A for the latest change date and then query database B to get all records with a change date later than that.
    Hi jmcilhinney

    Thanks for the advise I shall look into adapting the date to a date Feilds.

    Now I have to ask how can I use data that is in the record set from database 1 (server) to see if it needs updating in database 2 (local)

    I can get the results into a data reader (as I've been using them for ever) do I just look though the results and do a update / add etc on the records?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width