DEVBUZZ Homepage Developing an e-wallet using .NET Compact framework & SQL Server CE
 
Web www.devbuzz.com
  HOME PAGE
  All Articles
  Advertise
  Consulting

 Development
  Discuss - Forums
  Still in the box?
  .Compact Framework
  Code Snippets
  SQL Server CE
  Database
  MS Resources
 Stores
  Developer Controls
  Pocket PC Hardware
  Pocket PC Software
  Pocket PC Books
  .NET CF Books
  Book Reviews
  SPB SW Discounts
  RESCO SW Discounts
 DEVBUZZ Info
  About Us
  Help
  Join our email list
  Links & Ratings
  Press & Comments
  Pocket PC version
  Software Reviews
  Hardware Reviews
 Authors
  Authors
  Article Guide
  Competitions
 Resources
  Developers
  Register
  Login

  SPB Discounts!
 Columnists
  Rick Winscot
 Past Blast
  Personal Media Ctr
  Gizmobility
  eVB Legacy
  Old news
  Hosted Software
  Wireless
  Newsletters
  Carl Davis
  Upton Au

 Pocket PC Registry
  Join the registry
  View current list
 Current Poll
Are you converting to .NET Compact Framework?
Yes, it has changed my life!
No, I'm sticking with eVB
.NET CF what's that`?

Current results
3431 votes so far
 Recent Forum Threads [goto forums]

Get Computername
read... (67 hits)


Great aid to development productivity
read... (82 hits)


ThreadingTimer sample code
read... (143 hits)


Multithreading with .NET CF
read... (194 hits)


Moving from eMbedded Visual Basic to Visual Basic .NET
read... (166 hits)


.NET Compact Framework 2.0 Service Pack 2
read... (226 hits)


Transfer Data from SQL Server 2000 to SQL Server Compact Edition
read... (298 hits)


This protocol version is not supported
read... (236 hits)


Converting Lowercase to uppercase wont work
read... (203 hits)


Direct access to MS SQL Server 2000
read... (374 hits)


Creating SDF file in Desktop
read... (513 hits)


Winsock in CF.NET
read... (316 hits)


Using Pocket Outlook to submit HTML page form with MAILTO action
read... (420 hits)


Missing file "System.Data.PocketPC.asmmeta.dll"
read... (268 hits)


HP iPAQ hw6915 Serial Port Issue
read... (309 hits)


Info on the recent forum changes
read... (341 hits)


SqlServer tools from Redgate
read... (383 hits)


Arrow keys and Hardware navigation button
read... (393 hits)


O2 XDA lls pin sync cable to comport
read... (322 hits)


Creating dynamic folders on Pocket PC OS
read... (299 hits)

Custom Windows Mobile software development.
LBS Challenge 2007
LBS Challenge Eight previous NAVTEQ Global LBS Challenge® participants have received venture capital funding and nine past LBS Challenge winners have launched commercial applications on major wireless carriers. Register your non-commercial LBS application in the 2007 NAVTEQ Global LBS Challenge in one of three regions: Americas, Europe-Middle East-Africa (EMEA) or Asia-Pacific(APAC). You could win a share of $2 million in prizes. This could be your year.
Dream. Develop. Win.

Development | .NET Compact Framework

Developing an e-wallet using .NET Compact framework & SQL Server CE
Written by Gerald Schinagl  [author's bio]  [read 47589 times]
Edited by Derek

Download the code   Discuss this article   .NET Compact Framework   

Page 1  Page 2 

Why did I start coding the application ?

I work in a consulting company, so I usually have to deal with a large number of different user names and passwords of my customers systems, that are changing constantly. I have one set of passwords for customers intranets, another set of passwords for different users in different applications and databases, and of course I have a lot of customers.

Confusion reigns every time a login screen tells me my password was not accepted. This is usually the point at which an internal quiz starts; did I provide the password of User x in Database y of company z or was it the former Windows NT Password of my home network ?

Believe me, I have been groveling and pleading to Sysadmins more than once because I locked myself out of the system as I used the wrong passwords. And there is another factor that complicates issues. Most of my customers have strict rules on their passwords affecting what size the password must be, whether the password must contain numeric characters or not and whether the password can be the same as one of the last x passwords you have used. So I end up sitting in front of of the computer and racking my brain as to what were the last 9 passwords on that system I am now locked out of.

Starting to solve the problem

Thinking of a solution for that problem I decided to code a Password Database Application for my PDA, since I carry it with me almost all of the time. The PDA is secured with a PIN, so the device is more secure than plain paper and it is also possible to encrypt the database with another password. By using the Application I just have to remember my PDA´s PIN and (if I like to be more secure) one additional password instead of at least 300 passwords I had to remember before.

First I decided to write the application in eVB as a prototype, but when I signed up for the Mobility Developers Conference in London I decided to wait for the .NET Compact Framework (CF) Beta and to code that application as my first CF Application, written in VB.NET. Some days after getting my hands on the Beta I started coding the application (in fact I developed the data model at Heathrow Airport, waiting for my delayed flight back home). After installing the .NET Compact Framework on my machine I started to implement the SQL CE 2.0 Database and the application. Sometime later, whilst in the midst of coding I had to redesign the database, as some features that I know from the Desktop Version of SQL Server are not implemented in the CE Version (for example correlated subqueries and the TOP Clause) or are poor performers like complex views.

As I have installed the Smart Device Extensions on my computer, I have some additional features when starting a new Project. I decided to do a new SmartDevice Application in VB.NET. After the initial configuration Dialog (deciding whether the application is for Pocket PC or general CE 3.0) Visual Studio starts with a blank Form. As a next step the Namespace System.Data.SQLServerCE has to be added to the Project (Add reference...) From this point on all SQL CE methods and properties can be accessed. The really cool piece here is, that Visual Studio does all the installation/deployment of the needed SQL CE files to the device for you. As I don't own a permanent CF card for my PDA my database resides in the device´s RAM (keeping the Database on a CF card would be much better in terms of data-loss). As shown in the following snippet, Application checks whether a database already exists or not on initialization. If not (usually not on the first deployment) a predefined Database-File is created. After the creation of the data file a connection to the particular file is opened and the necessary tables and constraints are created.

If Not System.IO.File.Exists("\my documents &_
\delphip.sdf") Then
  Dim en As New Engine("data source =\ &_
      my documents\delphip.sdf")
  en.CreateDatabase()
  'The Connection Object (cn) is instantiated &_
      outside that Snippet !
  cn.Open()
  'Create the Database
  Dim command As New SqlCeCommand("CREATE TABLE &_
   company (comp_id int IDENTITY (1, 1) unique &_
   not null, company national character varying &_
  (30) Primary Key NOT NULL)", cn)
  command.ExecuteNonQuery()
  command.CommandText = "CREATE TABLE &_
   application (app_id int IDENTITY (1, 1) &_
   Primary Key NOT NULL ,comp_id int NOT NULL ,&_
   applikation national character varying (30) &_
   NOT NULL) "
  command.ExecuteNonQuery()
  command.CommandText = "CREATE TABLE passwords &_
   (user_id int NOT NULL , create_date datetime &_
   NOT NULL ,password national character varying &_
   (100) NOT NULL, active bit not null ) "
  command.ExecuteNonQuery()
  command.CommandText = "CREATE TABLE username &_
   (user_id int IDENTITY (1, 1) NOT NULL ,app_id &_
   int NOT NULL ,username national character &_
   varying (30) NOT NULL , last_pwd smallint NOT &_
   NULL , min_chr smallint NULL , numeric_in bit &_
   NOT NULL) "
  command.ExecuteNonQuery()
  command.CommandText = "CREATE UNIQUE INDEX &_
   idxapplikation ON application (comp_id, &_
   applikation)"
  command.ExecuteNonQuery()
  cn.Close()
End If

After you start debugging you will se a new icon (SQLCE Query) in the Start Menu of the Device that opens a Query Analyzer for windows CE. I won´t tell you more about that nice tool in this article, but one remember this: "Don't close the Query Analyzer by using the x (Analyzer is set to background) but use the Exit Command in the Tools Menu. Otherwise other applications will fail as SQL CE 2.0 supports only connection at a time (and the Query Analyser is will still be running in the background).

Next Page 

Back to .NET Compact Framework | [Article Index]

 

Back to the top of the page.
Chris De Herrera's Windows CE Website Windows CE News & Information Source
Copyright ©2000-2007 by DEVBUZZ.COM, Inc., NJ. USA.MSDEVELOP