Click here to Skip to main content
15,884,986 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.9K   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: connect to Sql server 2000 from Emulator Pin
tommyitvn4-Dec-06 14:46
tommyitvn4-Dec-06 14:46 
GeneralMySQL to SQL Server CE Pin
SarunMK12-Jul-05 17:52
SarunMK12-Jul-05 17:52 
GeneralRe: MySQL to SQL Server CE Pin
rasheed197913-Jul-05 21:42
rasheed197913-Jul-05 21:42 
GeneralRe: MySQL to SQL Server CE Pin
SarunMK14-Jul-05 20:51
SarunMK14-Jul-05 20:51 
GeneralRe: MySQL to SQL Server CE Pin
surpatel7813-Mar-07 3:50
surpatel7813-Mar-07 3:50 
Generalcould not connect with DB Pin
siddams6-Jul-05 20:45
siddams6-Jul-05 20:45 
GeneralRe: could not connect with DB Pin
rasheed19798-Jul-05 9:38
rasheed19798-Jul-05 9:38 
GeneralRe: could not connect with DB Pin
siddams11-Jul-05 19:34
siddams11-Jul-05 19:34 
Hi Rasheed!
Thanks ! You were right.There was a spelling mistake. Need another help . Can't locate Sscesa20.dll or sscesa10.dll files. so cant type the URL. help me please!!


siddams
GeneralRe: could not connect with DB Pin
rasheed197912-Jul-05 0:07
rasheed197912-Jul-05 0:07 
GeneralConnect to server using CDMA connection Pin
sridhar#net1-Jul-05 15:50
sridhar#net1-Jul-05 15:50 
GeneralRe: Help....Help "Connect to server using CDMA connection" Pin
rasheed19794-Jul-05 6:59
rasheed19794-Jul-05 6:59 
GeneralDataBinding Pin
Rossi4625-Jun-05 5:03
Rossi4625-Jun-05 5:03 
GeneralRe: DataBinding Pin
rasheed19794-Jul-05 6:57
rasheed19794-Jul-05 6:57 
GeneralStop - Start SQL Server CE Agent Services in PDA. Pin
Member 19533387-Jun-05 18:13
Member 19533387-Jun-05 18:13 
Generalsync Pocket PC and Desktop PC Pin
adrian.zhelev12-May-05 0:11
adrian.zhelev12-May-05 0:11 
GeneralRe: sync Pocket PC and Desktop PC Pin
rasheed197912-May-05 22:41
rasheed197912-May-05 22:41 
GeneralRe: sync Pocket PC and Desktop PC Pin
Adnan Siddiqi7-Jul-05 0:10
Adnan Siddiqi7-Jul-05 0:10 
GeneralRe: sync Pocket PC and Desktop PC Pin
rasheed19798-Jul-05 9:40
rasheed19798-Jul-05 9:40 
GeneralCan't Create DB Pin
Member 194911710-May-05 16:17
Member 194911710-May-05 16:17 
GeneralRe: Can't Create DB Pin
rasheed197910-May-05 22:56
rasheed197910-May-05 22:56 
GeneralRe: Can't Create DB Pin
MohdImranRizvi26128124-Nov-05 4:22
MohdImranRizvi26128124-Nov-05 4:22 
GeneralRDA Help me please Pin
Anonymous8-Dec-04 19:20
Anonymous8-Dec-04 19:20 
GeneralRe: RDA Help me please Pin
salai20-Mar-05 21:51
salai20-Mar-05 21:51 
GeneralModify sdf files on PC Pin
Eduardo Ramírez1-Oct-04 6:19
Eduardo Ramírez1-Oct-04 6:19 
GeneralSql Server Ce Pin
mathon5-Sep-04 23:55
mathon5-Sep-04 23:55 

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.