5,548,129 members and growing! (19,325 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » General     Intermediate

Pocket PC with SQL CE

By rasheed1979

This article demonstrates how to use SQL CE and SQL server 2000 with the help of Remote Data Access (RDA)
VB, Windows, .NET CF, .NET, MobileVS.NET2003, Visual Studio, Dev

Posted: 29 Jan 2004
Updated: 29 Jan 2004
Views: 137,398
Bookmarked: 33 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
23 votes for this Article.
Popularity: 3.69 Rating: 2.71 out of 5
7 votes, 30.4%
1
2 votes, 8.7%
2
2 votes, 8.7%
3
5 votes, 21.7%
4
7 votes, 30.4%
5

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
'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 :-

   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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

rasheed1979


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

Try to achive in different stream


Occupation: Architect
Location: India India

Other popular Mobile Development articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 68 (Total in Forum: 68) (Refresh)FirstPrevNext
Subject  Author Date 
Generalhelp Rasheed :(memberthree.leaf13:46 12 Sep '08  
Generalphone incoming call informationmemberprats11:28 15 Jun '07  
GeneralE r r o rmemberPavan_pareta1:13 2 Jun '07  
Generalmissing method exceptionmembermokhabarat13:21 3 May '07  
Generalsql expressmemberrajeshatsrin6:01 20 Apr '07  
QuestionError when synchronize data from Pocket PC to Pc and oppositemembertommyitvn20:21 5 Dec '06  
AnswerRe: Error when synchronize data from Pocket PC to Pc and oppositememberrasheed19792:20 22 Dec '06  
GeneralMissing Method Exceptionmembervictorarce7:56 7 Jul '06  
GeneralRe: Missing Method Exceptionmemberstorystar9:57 31 Oct '06  
Generalrasheed..plz helpmembersudhacnaidu19:47 8 Jun '06  
GeneralRe: rasheed..plz helpmembersudhacnaidu1:21 9 Jun '06  
GeneralRe: rasheed..plz helpmemberrasheed197917:55 11 Jun '06  
Generalerror with initialize SQLmembersudhacnaidu19:41 8 Jun '06  
GeneralBookmemberBaskras1213:58 4 May '06  
GeneralRe: Bookmemberacc12345678903:51 7 Mar '07  
GeneralNot able to SyncmemberArathi Vasupal0:45 27 Mar '06  
GeneralIs there away to send to Desktop Ms Accessmembersilkkeng17:19 7 Mar '06  
GeneralRe: Is there away to send to Desktop Ms Accessmemberrasheed197916:05 13 Mar '06  
GeneralProblem installing SQL server CEmemberronithefrnd18:45 1 Jan '06  
GeneralRe: Problem installing SQL server CEmemberrasheed197921:35 1 Jan '06  
GeneralRe: Problem installing SQL server CEmemberronithefrnd18:53 3 Jan '06  
Generalconnect to Sql server 2000 from EmulatormemberMr_NY18:05 22 Sep '05  
GeneralRe: connect to Sql server 2000 from Emulatormemberrasheed197921:33 1 Jan '06  
GeneralRe: connect to Sql server 2000 from Emulatormembertommyitvn15:46 4 Dec '06  
GeneralMySQL to SQL Server CEmemberSarunMK18:52 12 Jul '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 29 Jan 2004
Editor: Nishant Sivakumar
Copyright 2004 by rasheed1979
Everything else Copyright © CodeProject, 1999-2008
Web19 | Advertise on the Code Project