Click here to Skip to main content
Click here to Skip to main content

Using SQL Server CE Mobile with SQL Server through RDA

, 16 Nov 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
This article is on communicating with a server through Remote Data Access objects.

Sample Image - DBManager.jpg

Introduction

In this article, I will talk about Visual Studio .NET mobile developement and the use of RDA Remote Data Access) objects to access data and communicate with a PC. I will show how to synchronize your device with the server and share data. I will focus on RDA and replication. I developed the program for my HP Ipaq HW6500 series Pocket PC. So the screen size may not fit. But you can change it to fit your mobile device's screen size. 

Using the code

Just run the code. It will be installed to your device. The code needs SQL Server CE installed, and sscesa20.dll should be configured. The code uses SQL Server 2000 (2005 has the same manner though) with SP3 and Visual Studio 2003. You can find the required information from here.

An example of the souce code is given below. This is used to pull a table.

SqlCeConnection cn = null;
string rdaOleDbConnectString = 
    "Provider=sqloledb; Data Source=localhost;" + 
    "Initial Catalog=" + DbManager.glbConn.DbName + "; " +
    "User Id=" + DbManager.glbConn.DbUserId + 
    ";Password=" + DbManager.glbConn.DbPassword ;
SqlCeRemoteDataAccess rda = null;
try 
{
    rda = new SqlCeRemoteDataAccess();
    rda.InternetLogin          = DbManager.glbConn.WebUserId;
    rda.InternetPassword       = DbManager.glbConn.WebPassword;
    rda.InternetUrl            = http://+DbManager.glbConn.ServerIp+
                                 "/"+DbManager.glbConn.WebDir+
                                 "/sscesa20.dll";
    rda.LocalConnectionString ="Data Source=\\Program Files\\"+
                               this.txtLocalDb.Text + ".sdf";
    if (this.chkDropTable.Checked)
    { 
        cn = new SqlCeConnection(rda.LocalConnectionString);
        cn.Open();
        SqlCeCommand cmd = cn.CreateCommand();
        cmd.CommandText = "DROP TABLE " + this.txtLocalTable.Text;
        cmd.ExecuteNonQuery();
        if (cn.State != ConnectionState.Closed)
            cn.Close();
    }
    if (this.cmbTrackOption.Text=="TrackingOff")
        rda.Pull(this.txtLocalTable.Text, 
          this.txtQuery.Text, 
          rdaOleDbConnectString,
          RdaTrackOption.TrackingOff,
          "ErrorTable");
    if (this.cmbTrackOption.Text=="TrackingOn")
        rda.Pull(this.txtLocalTable.Text, 
          this.txtQuery.Text, 
          rdaOleDbConnectString,
          RdaTrackOption.TrackingOn,
          "ErrorTable");
    if (this.cmbTrackOption.Text=="TrackingOffWithIndexes")
        rda.Pull(this.txtLocalTable.Text, 
          this.txtQuery.Text, 
          rdaOleDbConnectString,
          RdaTrackOption.TrackingOffWithIndexes,
          "ErrorTable"); ...

Key Points

Unless you enter the names and types of the server parameters correctly, you won't be able to use the DA objects, so please be careful about it.

Please notice that rather than using a DataSet for the DataGrid, one must use DataReaders to make efficient use of memmory.

Also, you have to ensure that sscesa20.dll is configured and working correctly. Make sure the path is right.

Lastly...

As I develop more, I will come up with other Mobile examples.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Tolga Birdal
CEO Gravi Information Technologies and Consultancy Ltd
Turkey Turkey
Currently, also an MSc. student in Technical University of Munich, I develop practical application in computer vision for more than 5 years. I design real-time solutions to industrial and practical vision problems, both 3D and 2D. Very interested in developing algorithms in C relating math and vision.
 
Please visit Gravi's web page (http://www.gravi.com.tr) and my page (http://www.tbirdal.me) to learn more about what we develop.
 
I admire performance in algorithms.
 
"Great minds never die, they just tend to infinity..."
Follow on   LinkedIn

Comments and Discussions

 
Generala bug! Pinmember885313138-Oct-08 1:47 
Generalmissing method exception Pinmembermokhabarat3-May-07 13:20 
GeneralRe: missing method exception PinmemberTolga Birdal4-May-07 0:47 
Generalcontact Pinmembertheboescho14-Dec-06 8:52 
QuestionComms over GPRS Pinmemberdjgann19-Nov-06 21:27 
AnswerRe: Comms over GPRS PinmemberTolga Birdal21-Nov-06 14:48 
GeneralRe: Comms over GPRS PinmemberTolga Birdal21-Nov-06 14:48 
GeneralRe: Comms over GPRS PinmemberTolga Birdal22-Nov-06 12:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411023.1 | Last Updated 16 Nov 2006
Article Copyright 2006 by Tolga Birdal
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid