Solved

Converting SQL database to a sdf file

Posted on 2003-10-30
2
918 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
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.

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now