Synchronisation between SQL Server 2008 Express and VFP tables - c#-3.0

I'm looking for advices and suggestions on how to synchronise data between two databases.
The first database is a SQL Server 2008 Express that run on disconnected laptops (no network or internet access). The second database (main) is a VFP 9.0 that run on a server.
When the user connect their laptop on the network, I want the synchronisation process to go through.
Other than the different database engines, I have the following items to take into account:
The tables don't necessary have the same structure
The primary keys are not the same (GUID in the SQL Server and often a combination of character fields in VFP)
Synchronisation of the tables must be done in a certain order to respect the parent-child relationships
On some insert on the SQL Server side, a new primary key must be generated and synchronised in the VFP table
A bunch of validations must be made and some feedback from the user are sometimes needed
Not all records need to be synchronised
Some records on the SQL Server need to be deleted after the syncronisation
Need to take into account deleted records from both side
Minimal modifications need to be done on the VFP database
There are probably other points I'm forgotting now, but I think you get the idea of the challenge I face. My guess right now are that I will need to build a custom synchronisation module, but I want your input before I go on in case I overlooked some options and to get some tips on how to approach this.
I looked rapidly at Microsoft Sync Framework, but with all the restrictions I have and the fact that there is no VFP client already built (AFAIK), I don't think it will be of great help.
Thanks in advance for your feedback.
Update: The laptop application is a C# WinForm application and is using SQL Server 2008 Express.

The complexity of the situation and requirements leads me to believe you need to write a Visual FoxPro application. Visual FoxPro connects to SQL Server 2008 data easily. The complexity of the code is matching the requirements and identifying the data that needs to be synched, not the syntax. Visual FoxPro strength is in the data manipulation language and the ability to connect to almost any data source (native DBFs, ODBC, ADO, and XML).
SQL Server can read VFP 9 data via the VFP 9 OLE DB driver. You could write T-SQL stored procedures to get to the VFP data. Not sure how it would recognize the laptop being connected to the network though.
Another approach is to use SQL Server XML Diffgrams. I am not an expert by any stretch of the imagination on this approach, but it would be something you can research.
Since my expertise is with Visual FoxPro I would find it way easier to go the other way though, but that is just me. You have to go with the skillset of the resources you have for the project.
VFP reads and writes SQL Server data via a connection (DSN, ConnectionString) and any technique involving SQL Passthrough (SQLConnect(), SQLExec() and SQLDisconnect()), CursorAdapters, Remote Views, or a combination of the three.
A Visual FoxPro program can also recognize Windows Events like connecting to a network. The application could be installed on each laptop and running to recognize the Windows Event. Once the event is raised the application can attempt to connect to the SQL Server database (possible it is connecting to a network without the SQL Server available or a different network).
Once connected it runs the logic to check and synchronize the databases.
Sounds like you don't have a lot of control over the application writing to the VFP 9 data on the laptop. If you do have control over the application writing to the VFP 9 database you might consider changing the app to write to a SQL Server Express instance on the laptop and then you can use SQL Server replication to manage the synchronization. Not a trivial task though and SQL Server replication, while getting better with each release, does cause hair loss in DBAs. Definitely a lot of work going this route.
Rick Schummer
Visual FoxPro MVP

I would encourage you to take another look at MS sync framework. We have a situation where we want to synchronize occasionally connected C# clients apps with our Java/Oracle backend. You can use the sync framework providers for the C# client and implement your own custom subclass of KnowledgeSyncProvider for the backend. This will get you half-way there, and show you a good pattern to apply for the rest.

Related

Transition from legacy database to new one that works with legacy application

I have a problem concerning legacy application that can’t be changed in any way (single executable file with no dlls) which is connected to a database that can be changed. It is a visual basic 6 application connecting to the database using ADO.Net. Database engine is a SQL Server 2008. The goal is to create new correct database that will work with legacy application
It is coupled so tightly, that it does not even work with views instead of tables as suggested here. So the present situation look like this: current situation diagram
Currently I am trying to research into the problem and find my options. I have some idea that might work:
Since the approach to change tables to views does not work, I think that one possibility is to intercept the communication between app and legacy DB, read a sent command and redirect it somewhere else and not letting legacy db respond to the request.
Each command is either CRUD or procedure execution and we know what possible commands can be sent. Let’s suppose that a new database is set and has views corresponding to the legacy one. Commands are redirected to my own application that filters out everything and manipulates it (somehow) to work with the new schema.
Diagram of intercepted communication
This is my general idea of what I want to do to avoid rewriting the legacy application which is tightly coupled. Someone already asked a question similar to mine.
They discuss approach how to either dig commands from sql dump files or to intercept the communication.
The interception itself doesn’t seem to be a problem as discussed here. But I wonder how can the mirror reply.
The same goes for port mirroring using [TCP packet hijacking] (https://reverseengineering.stackexchange.com/a/1816)
To sum up, my questions are as follows:
Is that feasible approach to achieve smooth transition from a legacy modifiable solution to new one?
If my idea is doable, how can I listen to db requests and create responses from a different application and not the original db?
Is there a better way how to achieve my goal which is to create new database with database abstraction layer so the old legacy application will remain functional?

Can we connect external data to k2?

I am new to K2 and have to check how similar is it to MS Access. So I need to know whether we connect external data from example from SQL server to K2.
Yes, K2 uses SmartObjects to connect to external data sources (like SQL Server).
Absolutely! Connecting with many disparate repositories of data is K2's great strength.
To connect to a SQL Server, you simply have to create an instance of the SQL service broker, with the details of the server and database you want to read from. Then you can create a SmartObject for each table, view, or stored procedure within that SQL Server database that you need to interact with.
The following thread on K2 Community should get you started: http://community.k2.com/t5/K2-blackpearl/How-to-connect-K2-blackpearl-with-MS-SQL-R2/td-p/53993
K2 is not similar to Access since it is larger platform which meets enterprise workflow automation needs whereas Access would rather allow you to build department level apps with little flexibility - so comparison is incorrect neither from feature set nor from product positioning or pricing point of views.
K2 has 3 major pillars tightly integrated with each other:
Workflow Engine (manages execution of steps defined for process you automating)
SmartForms (allow to build you web UI to your apps and processes)
SmartObjects - this abstraction layer offers you set of OOB connectors which allow you to consume or write data from variety of external LOB systems - SQL Server, Oracle, SharePoint and many more. Custom brokers can be created to connect to any other LOB system which is not covered by OOB brokers set.
So in terms of connecting to different to external data you won't have any problems and capabilities are far greater than those you may find in MS Access. Comparing those two things it is almost like compare SMB shared folder VS SharePoint Server or something like this.
Also product being marketed (and build in that way) to allow "code-less development" - it has really gentle learning curve / allows you to start quick with building your applications.

Merging two database into single database

I have deployed same application in two different computers. Now i need to merge both data from two different database into single database.
The application is developed using c# .net and uses sql express 2008.
The problem arised because i could not use the application over LAN.
So i need to merge the two database into one.
So please help me to solve the problem to merge it.
I also need to run the application over LAN but the sqlbrowser doesnot start and i have searched the internet for the answer but i haven't been lucky.
thank you, waiting for response.
The approach you want to take will depend largely on your schema, but Microsoft Sync Framework should likely be useful. It would let you define rules for resolving conflicts and merging your data.
As for accessing your data over the LAN, this post has a good overview of what it takes to enable remote access to your SQL Server Express.

How to synchronize from SQL Express 2008 to SQL Server 2008?

I have an app the runs at the store level extracting data out of a POS system. This app asks the POS system for data which in return produces some .DBF files. The app loads the DBFs in memory and saves it to SQL Server 2008 Express at the store level. This happens at 3 different stores.
I have been looking into the Microsoft Sync Framework, but have not come across any good examples of how to sync tables in one direction only, from each of the stores into a single database at the corporate level.
The data at each one of the stores is being managed by the app(delete, update, insert).
Does anyone know a good article, that I could read about synchronizing SQL data?
Thank you.
Try the following link
http://www.codeproject.com/KB/database/DTS_SQLExpress.aspx

Is it possible to use Entity Framework with a DB2 iSeries AS/400

Im new to Microsoft entity framework and wonders if it's possible to use this framework with a DB2 iSeries AS/400? Are there any problems at all when working with this kind of "legacy systems"? and the EF framework?
You can use Entity Framework to connect to an ISeries DB2 database one of three ways:
1. If you purchase the license to IBM's DB2 Connect product. The license is around $12,000 which is outrageous. Also, there is not enough good documentation for how the DB2 Connect product actually works, how it installs, or its possible benefits. I've contacted one of their resellers to get a test install and it was not an intuitive process so we never purchased the product. Likewise, there doesn't appear to be any demos. I don't understand how IBM can have one of the best servers available but don't bend over backwards to leverage their product to Microsoft developers.
That said, if you research this topic you will find much information saying that you can use Entity Framework using their ADO.Net data server provider. I went down this path but I will warn you that their data server provider only works when DB2 connect is installed. This is confusing because IBM advertises this ability but doesn't often show the direct correlation between the two products so you're often left thinking that it will work without db2 connect which it will not at this time.
2. Purchase a third party data provider designed for Entity Framework. Progress software's Data Direct is super easy to use. I don't like how their server licensing works though because their server license is per core processor for your app server. This is flawed because this assumes you only have one app server when in reality, people regularly need to have different app servers for load balancing. I would prefer they just license per one ISeries server. However, you can purchase the licenses for each individual user if you decide to do that.
3. Write your own data provider. This is possible but there are obvious drawbacks.
It sort of looks like it is - see here:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.swg.im.dbclient.adonet.doc/doc/c0054118.html?resultof=%22%65%6e%74%69%74%79%22%20%22%65%6e%74%69%74%69%22%20%22%66%72%61%6d%65%77%6f%72%6b%22%20
but quite honestly, I'm not 100% sure - especially not if it supports EF 4.0 (yet).
Or check out the IBM DB2Connect site and search from there...