Click here to Skip to main content
6,596,602 members and growing! (23,148 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » General     Intermediate License: The Code Project Open License (CPOL)

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, Dev
Posted:29 Jan 2004
Views:160,174
Bookmarked:41 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
26 votes for this article.
Popularity: 3.86 Rating: 2.73 out of 5
7 votes, 26.9%
1
3 votes, 11.5%
2
2 votes, 7.7%
3
6 votes, 23.1%
4
8 votes, 30.8%
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

rasheed1979


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

Try to achive in different stream
Location: India India

Other popular Mobile Development articles:

  • Writing Your Own GPS Applications: Part 2
    In part two of the series, the author of "GPS.NET" teaches developers how to write GPS applications suitable for the real world by mastering GPS precision concepts. Source code includes a working NMEA interpreter and sample high-precision application in C# and VB.NET.
  • Writing Your Own GPS Applications: Part I
    What is it that GPS applications need to be good enough to use for in-car navigation? Also, how does the process of interpreting GPS data actually work? In this three-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application.
  • Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant
    A step by step tutorial for getting GPS from any SmartPhone, even without GPS built in, and then making location useful.
  • iPhone UI in Windows Mobile
    It's an interface that works with transparency effects. As a sample I used an interface just like the iPhone one. In this tutorial I am explaining how simple is working with transparency on Windows Mobile.
  • Pocket 1945 - A C# .NET CF Shooter
    An article on Pocket PC game development
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 74 (Total in Forum: 74) (Refresh)FirstPrevNext
GeneralMy vote of 2 PinmemberRob Graham6:01 5 May '09  
Generaldb connection error Pinmemberashuangrish22:44 27 Nov '08  
GeneralRe: db connection error Pinmemberrasheed197919:38 30 Nov '08  
GeneralRe: db connection error Pinmemberashuangrish1:53 1 Dec '08  
GeneralRe: db connection error Pinmemberashuangrish1:28 5 Dec '08  
GeneralRe: db connection error Pinmemberomid20029:05 23 Feb '09  
Generalhelp Rasheed :( Pinmemberthree.leaf13:46 12 Sep '08  
Generalphone incoming call information Pinmemberprats11:28 15 Jun '07  
GeneralE r r o r PinmemberPavan_pareta1:13 2 Jun '07  
Generalmissing method exception Pinmembermokhabarat13:21 3 May '07  
Generalsql express Pinmemberrajeshatsrin6:01 20 Apr '07  
QuestionError when synchronize data from Pocket PC to Pc and opposite Pinmembertommyitvn20:21 5 Dec '06  
AnswerRe: Error when synchronize data from Pocket PC to Pc and opposite Pinmemberrasheed19792:20 22 Dec '06  
GeneralMissing Method Exception Pinmembervictorarce7:56 7 Jul '06  
GeneralRe: Missing Method Exception Pinmemberstorystar9:57 31 Oct '06  
Generalrasheed..plz help Pinmembersudhacnaidu19:47 8 Jun '06  
GeneralRe: rasheed..plz help Pinmembersudhacnaidu1:21 9 Jun '06  
GeneralRe: rasheed..plz help Pinmemberrasheed197917:55 11 Jun '06  
Generalerror with initialize SQL Pinmembersudhacnaidu19:41 8 Jun '06  
GeneralBook PinmemberBaskras1213:58 4 May '06  
GeneralRe: Book Pinmemberacc12345678903:51 7 Mar '07  
GeneralNot able to Sync PinmemberArathi Vasupal0:45 27 Mar '06  
GeneralIs there away to send to Desktop Ms Access Pinmembersilkkeng17:19 7 Mar '06  
GeneralRe: Is there away to send to Desktop Ms Access Pinmemberrasheed197916:05 13 Mar '06  
GeneralProblem installing SQL server CE Pinmemberronithefrnd18:45 1 Jan '06  

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-2009
Web15 | Advertise on the Code Project