Exporting SQL Server Databases for offline use - sql-server

I have a desktop application (C# .NET 3.5) that uses a SQL server for it's database. I have had a request from the client, however, to make it possible to export the database as it stands, and be able to use it on a laptop without connectivity. They understand that updates to the parent server will not be reflected in these offline clients.
Is there a way I can just save the DataSet's to a binary form and write them to a disk and send those files to the offline clients.

There is an entire line of tools and technologies covering this case, namely the Synch Framework. See Synchronizing Databases. See Getting Started: Client and Server Synchronization for a starting example involving a SQL Server Compact Edition file on the client (.SDF file) that is synchronized with a SQL Server central database. Note that the client won't install anything else other than you application, the SQL Server CE is just a few in-process DLLs that you distribute with your app, nothing nearly as complex as a SQL Express edition on the client.
The good news is that Synch Framework no only allows the client to get their own on-the-go snapshot of the database, it actually allows for changes applied while disconnected to be merged back into the central site.

You could either use Compact Edition (aka. SDF files), or you can save the datasets as XML using the built-in method.

Can't you just take a SQL Server level backup and have them install e.g. SQL Server Express on their laptops and restore the database there?
That way you wouldn't have to do anything special in your app at all - just change the connection string to point to the local SQL Server Express instance, and off you go! No mucking around with serialized data sets and stuff......

Related

What are my options for accessing an SQL Server database through MS Access front-end while offline

I'm currently working on a project proposal which would require moving multiple Access databases into a new MS SQL Server database. The idea is to keep the front end program as MS Access so that the users are familiar with the process of inputting data and creating reports.
However, things get complicated in that the internet in the areas where the survey will be collected has poor connectivity and will be out from time to time. I had thought of a few ways of solving this issue but all of them are cumbersome:
1) Having a PC with a router that stores the SQL Server database in offline mode and the data entry PCs connect to the PC with the offline database through the router. The PC with the SQL Server database can then backup the db on the server when it has an internet connection.
2) Adding the data to MS Access databases that can then be merged with the SQL Server at specified increments (this would probably cause some issues).
We've done option 1 before for similar projects but never for connecting to an SQL Server database in offline mode. However, it seems feasible.
My question is: Does anyone know of a way of using Access as a front end application for SQL Server and being able to update data during times without internet connectivity? The SQL Server database would automatically assign primary keys, so, duplicate unique values shouldn't be an issue while syncing the data.
Thanks for your help. I've been having a hard time finding an answer on Google and syncing to databases is complicated at the best of times. I'm really just looking for a starting point to see if there are easier ways of accomplishing this.
I would run a the free editon of SQL express on all laptops. So the Access database would be the front end to the local edition of SQL express. SQL express can be a subscriber to the "main" sql database. You thus use SQL replication to sync those local editions of SQL server to the master server. Of course the main SQL server can't be the free edition of SQL server. So to publish the database for replication, you can't use the free edition, but those free editions can certainly be used as subscribers.
This approach would eliminate the need to build or write special software for the Access application. You thus do a traditional migration of the access back end (data tables) to sql server, and then simply run the Access application local with sql express installed on each laptop. You then fire off a sync to the main edition of sql server when such laptops are back at the office.
The other possible would be to adopt and use the net sync framework. This would also allow sync, and would eliminate the need to run sql expess on each machine. I think the least amount of effort is to sync the local editions of sql express with the main editon of SQL server running at the office (but that office edition of SQL server can't be a free edition).

Using Microsoft SQL Server with Windows Forms application (vb.net)

Ever since I started vb.Net programming, I have been using MS Access as back-end for all my programs.
It is easy to publish application with the MS Access database and run it on another PC without installing the MS Access database.
But now, the project I am working on needs a database with high storage capacity which means MS Access is no longer an option and I have chosen to use SQL Server. Now my question is do I have to install SQL Server on any system that the application will be run on? If so, how will I copy the database that I created on my development machine to other system so that my application will connect to it? Or is there any simpler way of doing this?
SQL Server is a client/server DBMS so you only install the database on the shared server. .NET includes SqlClient, which provides the client components needed for SQL Server applications.
There are a number of options for database deployment. Although you could use restore or attach your development database for the initial database deployment, that won't work well for future upgrades (assuming you want to keep data). Consider using T-SQL scripts and/or SQL Server Data Tools (SSDT). That will allow you to create new databases, such as for development and testing, as well as upgrade existing ones.

Why can't I save an SQL database on the server itself?

I'm trying to set up an SQL server for my web-server to send and receive data from. I'm somewhat confused on how the whole SQL server thing works though. I was wondering why I need a separate server for my SQL and my web server. why can't I save an SQL database on the server itself instead and access it the same way one would read and write an XML or JSON file on the server to store data?
You may be getting caught up with server, as in the computer its running on (physical box, virtual machine, might be easier to think of it as the operating system) vs the server, as in web server/sql server which are different software packages.
So the SQL server (software) and the Web server (software) can run on the same server (hardware, essentially).
Depending on your use case its usually best to have the SQL server on a different server (hardware) to your web server so that there is more dedicated resources for their processes, but its not required.
If you are asking why you cant talk to the database file directly, (in the case of MS SQL Server, at least) the server manages its own permissions and manages all the file IO for you. Its a bit more complicated than a JSON file.

Occasionally connected application (SQL Server data synchronization)

There is a central server that is running SQL Server 2008 R2 and WinForms clients, which use SQL Server CE to cache data. Data can be changed on both the server and client side. Each user can only edit his own data and view some of the data of other users. For example, a user can create a "Contract" and upload it to the server via synchronization, other users need to see this "Contract", except for customer's contact information, etc.
What a way to synchronize data is most suitable for this task?
Thanks in advance.
you can use Sync Framework to synchronize the local cache to a central server. You can either use the Local Database Cache Wizard in Visual Studio or code the sync yourself.
see Synchronizing SQL Server and SQL Server Compact
or Programming Common Client and Server Synchronization Tasks

Free FoxPro DB to SQL Server DB sync tool

Which software can you recommend to sync data from a FoxPro source to a SQL Server destination?
Here are a couple links with information that might be of help:
Migrating From Visual FoxPro
VFP conversion to support SQL server Backend
At my company we have data being written to foxpro tables daily, and are synced to SQL Server nightly using SSIS, so for the actual conversion I recommend that.
Getting the foxpro data to your central location could be accomplished by transferring the foxpro files via FTP (we've done this for years), or you could set up some sort of Web Service.
I don't think you'll find a tool to do this automatically and on a scheduled basis especially if they are geographically remote and the sync has to happen over the public internet. I'd be looking at writing a web service of some sort, which will sit on a server on the VFP side with methods to expose the VFP data, and another service on the SQL Server side to access that web service periodically and perform CRUD operations.

Resources