Click here to Skip to main content
15,867,453 members
Articles / Mobile Apps

Pocket PC with SQL CE

Rate me:
Please Sign up or sign in to vote.
2.76/5 (26 votes)
29 Jan 2004CPOL2 min read 246.1K   583   45   74
This article demonstrates how to use SQL CE and SQL Server 2000 with the help of Remote Data Access (RDA)

Introduction

This article describes how to use SQL CE using VB. NET and how to transfer data from SQLCE (Pocket PC) to SQL Server 2000 which is running in your desktop system.

Client Requirement

  1. Pocket PC with Microsoft Windows powered
  2. Microsoft .Net compact Framework 1.0 (Default in PocketPC)

Server Requirement

  1. MS SQL server 2000 with SP3
  2. MS SQL CE 2000 with SP3
  3. Create DataBase named D1Temp and execute script "D1temp SQLScript.sql"

Background

The basic idea behind this work is to update any information on the fly. i.e. If I am traveling from one location to another location if I seen
or knowing some interesting information. If I want those information to my data storage then just need a pocket PC and Internet connection.

On the flight I can note all the information and transfer the same to my desktop, which is running in some part of the world. I won't worry about the memory size of my Pocket PC because all the information is posted to the remote database.

You can make this work as a template and do your own mobile device application.

Using the code

Download the source code in that you can find a SQL script named SQLSCRIPT.sql. Create a Database (I used D1Temp) and run the script. Open Config.xml and specify correctly

  • DatabaseServer
  • DatabaseName
  • DatabaseLogin
  • DatabasePassword
  • SQLCEURL
  • IISLogin
  • IISPassword
If you are not properly configure this XML file then you will not get the expected result. Note: Make sure you are properly configured your SQLCE virtual folder and the IIS. The Database.vb files holds all the database related connections and query handling. The below code is used to connect to the Host database and populate the data to SQL CE
VB.NET
'Connect to SQL 2000
Dim rdaOleDbConnectString As String = _
  "Provider=sqloledb; Data Source=" & _
  oDBConfig.DatabaseServer & ";Initial" & _
  " Catalog=" & oDBConfig.PublisherDB & ";User Id=" & _
  oDBConfig.PublisherLogin & ";Password=" & _
  oDBConfig.PublisherPassword

  'create an RDA object to connect to the SQL Server CE 
  'database on the mobile device: 
  'Initialize the RDA object.
  Try
    rda = New SqlCeRemoteDataAccess

    rda.InternetUrl = oDBConfig.SqlCeUrl
    rda.LocalConnectionString = _
    "Provider=Microsoft.SQLSERVER." & _
    "OLEDB.CE.2.0;Data Source=" & oDBConfig.LocalDBLocation & _
    oDBConfig.LocalDBName

    rda.InternetLogin = oDBConfig.IISLogin
    rda.InternetPassword = oDBConfig.IISPassword

    'Pull from SQL 2000
    rda.Pull("MyFavourite", "Select * from MyFavourite", _
    rdaOleDbConnectString, _
    RdaTrackOption.TrackingOnWithIndexes)
    .....        

Getting back the details from PDA to SQL 2000 also same as above code except rda.Pull. Here we have to use rda.push :-

VB.NET
rda.Push("MyFavourite", rdaOleDbConnectString, _
RdaBatchOption.BatchingOn)
And also I added some of functions for getting data into DataReader and executing SQL statements.

Points of Interest

When I tried using the emulator most of time it shows error "80072EFD request send data to the computer running IIS has failed for more information see HRESULT" even everything is configured properly. If I use my pocket PC instead of Emulator it works good. After that I used to run the SQL CE virtual folder path "http://sys1/sqlce/sscesa20.dll" often through my IE . Some times it works but most of time it does not. If this trick fails then I used this logic i.e. I will change IISLogin from "everest/rasheed" to "everest\rasheed" (Just changed the slash) if it fails next time then I will change IISLogin from "everest\rasheed" to "everest/rasheed" You won't believe it but this worked perfectly. I didn't know the secret of "slash" ;-)

History

  • First release 1.0

License

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


Written By
India India
Called as Rasheed. Completed Master of Computer science. Working as Senior Consultant in Chennai, India.

Try to achive in different stream

Comments and Discussions

 
GeneralRe: Good Work Buddy - Problem 1 Pin
rasheed197923-Jul-04 22:03
rasheed197923-Jul-04 22:03 
GeneralRe: Good Work Buddy - Problem 1 Pin
MOISJWang25-Jul-04 3:05
MOISJWang25-Jul-04 3:05 
GeneralRe: Good Work Buddy - Problem 1 Pin
celikol24-Jul-05 23:10
celikol24-Jul-05 23:10 
GeneralRe: Good Work Buddy - Problem 1 Pin
Amey Chavan21-Oct-05 19:03
Amey Chavan21-Oct-05 19:03 
GeneralRe: Good Work Buddy - Problem 1 Pin
Anonymous25-Oct-05 18:30
Anonymous25-Oct-05 18:30 
GeneralError with DB1.cdb Pin
kkw200430-Jun-04 7:27
kkw200430-Jun-04 7:27 
GeneralRe: Error with DB1.cdb Pin
rasheed197930-Jun-04 15:58
rasheed197930-Jun-04 15:58 
GeneralRe: Error with DB1.cdb Pin
kkw20041-Jul-04 5:21
kkw20041-Jul-04 5:21 
Thanks Rasheed,

I'm using MSAccess 2000 (9.0.3821 SR-1)

KKW
GeneralRe: Error with DB1.cdb Pin
rasheed19791-Jul-04 23:18
rasheed19791-Jul-04 23:18 
Generalerror using MyFavourite Pin
lvTH23-Jun-04 5:49
lvTH23-Jun-04 5:49 
GeneralRe: error using MyFavourite Pin
rasheed197930-Jun-04 16:00
rasheed197930-Jun-04 16:00 
GeneralRe: error using MyFavourite Pin
lvTH30-Jun-04 21:10
lvTH30-Jun-04 21:10 
GeneralPocket PC Pin
Aviram Solomon30-Apr-04 2:34
Aviram Solomon30-Apr-04 2:34 
QuestionSynchronising without IIS? Pin
rpadayachee28-Apr-04 3:25
rpadayachee28-Apr-04 3:25 
AnswerRe: Synchronising without IIS? Pin
rasheed197926-May-04 16:31
rasheed197926-May-04 16:31 
AnswerRe: Synchronising without IIS? Pin
salai20-Mar-05 19:52
salai20-Mar-05 19:52 
Generalgreat code.... [modified] Pin
dharani17-Mar-04 20:11
dharani17-Mar-04 20:11 

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

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