Solved

Converting SQL database to a sdf file

Posted on 2003-10-30
2
920 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
2 Comments
 
LVL 5

Accepted Solution

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

Expert Comment

by:dishanf
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

770 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