Solved

Converting SQL database to a sdf file

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Calculate values in an array 18 36
SQL Select JOIN table 2 24
SQL Server Express 10 28
Update SQL to SP1 on SCCM server 7 17
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 …
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
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.

863 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

25 Experts available now in Live!

Get 1:1 Help Now