Solved

Converting SQL database to a sdf file

Posted on 2003-10-30
2
922 Views
Last Modified: 2011-10-03
I have a SQL database and I store all the information on that. I want this database to be accessed from pocket pc's. For this reason I had to convert all my database to a *.sdf file format so that the pocket pc user may use it.
I need a code on c#.net which can provide me a sdf file from SQL database.
0
Comment
Question by:burakbaysal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
russellshome earned 500 total points
ID: 9648575
0
 
LVL 8

Expert Comment

by:Dishan Fernando
ID: 9648616
/// Creating the replication object
SqlCeReplication oRepl = new SqlCeReplication(
      txtInternetUrl.Text, //@"http://10.20.10.81/SSCEGateway20/sscesa20.dll"
      txtInternetUserName.Text,
      txtInternetPassword.Text,
      txtPublisher.Text, // server name
      txtPublisherDatabase.Text,
      txtPublication.Text,
      txtSubscriber.Text,
      "Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=\My Documents\db.sdf"
      );

// Setting the HostName to the same value as the Subscriber for
// dynamic filtering on SQL Server
oRepl.HostName = txtSubscriber.Text;

/// Checking if a subscriber database already exists
if (!System.IO.File.Exists( txtSubscriberConnection.Text ) )
{
      /// Subscriber database does not exist. So creating a new
      /// subscription database
      oRepl.AddSubscription(AddOption.CreateDatabase);

}// end if

/// Performing the merge synchronization
oRepl.Synchronize();
      
MessageBox.Show("Sync Complete!");

/// Disposing the replication object
oRepl.Dispose();
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question