developing windows mobile applications · why develop windows mobile database ali i ?applications?...

28
DEVELOPING WINDOWS MOBILE APPLICATIONS TOM SLEE TOM SLEE SQL ANYWHERE PRODUCT MANAGEMENT AUGUST 2009

Upload: others

Post on 13-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

DEVELOPING WINDOWS MOBILE APPLICATIONSTOM SLEETOM SLEESQL ANYWHERE PRODUCT MANAGEMENT

AUGUST 2009

Page 2: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

AbstractAbstract

B i l l t ti i t d t d l i d t• Beginner‐level presentation introduces you to developing data‐

driven applications for Windows Mobile devices and .NET 

programming languages.

• Topics include:

• SQL Anywhere for Windows Mobile, 

• UltraLite database,,

• MobiLink data synchronization, 

• Visual Studio integrationVisual Studio integration.

Page 3: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

AgendaAgenda

Wh D l Wi d M bil D t b A li ti ?• Why Develop Windows Mobile Database Applications?

• SQL Anywhere for Windows Mobile – Overview

• Installation

• Development Requirements

• Getting Started – Demonstration

• Server Optionsp

• Visual Studio Development – Demonstration

• Deploying the Database

• Adding Synchronization with MobiLink Demonstration• Adding Synchronization with MobiLink – Demonstration

• Security Considerations

• Additional Resources

Page 4: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Why Develop Windows Mobile Database A li i ?Applications?

• Windows Mobile prevalent at the front lines of businessp• Some examples: sales force automation, mobile healthcare, surveying, 

logistics, hospitality, inspection

• Lower hardware and maintenance costs than laptopLower hardware and maintenance costs than laptop

• Specialized or ruggedized handhelds for specific needs

• Built‐in cell phone and wireless for business needs

b lif d d i• Long battery life compared to consumer devices

Page 5: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Why Develop Windows Mobile Database A li i ? ( )Applications? (cont.)

• Benefits of mobile database applicationspp• Offline access to data

• Only deploy data subsets specific to end‐user

• Bi directional synchronization to enterprise backends• Bi‐directional synchronization to enterprise backends

• Synchronize only changes

• Synchronize only when required Reduce costs

Page 6: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Why Develop Windows Mobile Database A li i ? ( )Applications? (cont.)

• End‐users demand…• Powerful applications that are easy to use

• Quick access to data at all times

• Security for stored information and data transmission• Security for stored information and data transmission

• Developers demand…• Rich functionality to implement requirements

• High performance for data access and manipulation

• Minimal database maintenanceMinimal database maintenance

• Robust data exchange capabilities

• End‐to‐end security (encryption)

Page 7: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

SQL Anywhere for WM ‐ OverviewSQL Anywhere for WM  Overview

• Full SQL support (views, stored procedures, user‐defined Q pp ( , p ,functions)

• High performance out of the box (dynamic cache sizing, cost‐b d ti i )based optimizer)

• Self‐administration features (automatic recovery, performance tuning, and conflict detection)g, )

• Bi‐directional synchronization to Sybase, Oracle, SQL Server, DB2 and MySQL

• 128‐bit strong encryption of database and communication streams

Page 8: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

InstallationInstallation

• Install from Windows desktop (Deployment Wizard)• Full install is 20 MB, typical is 10 MB – small footprint

• Install in main memory or storage card

• Supports up to Windows Mobile 6 (all editions)

• Saves CAB file for future deployments

• Localization• Software: 5 languages (en/fr/de/jp/zh)g g ( / / /jp/ )

• Deployment: 9 additional languages

• Available interfaces: ADO.NET, ODBC, Embedded SQL

• Additional components:• Additional components:• MobiLink and SQL Remote synchronization

• QAnywhere messaging

Page 9: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Development RequirementsDevelopment Requirements

• Sybase Central and Interactive SQL Admin Toolsy Q• Create new databases, add schema, add data

• Perform ad‐hoc queries

• Create synchronization models for existing schemas• Create synchronization models for existing schemas

• Debug stored procedures and functions

• Application profiling

• Programming Environment• Visual Studio 2005 or 2008 (.NET CF 2.0 and higher)

• PocketBuilderPocketBuilder

• JDBC (?)

Page 10: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Getting StartedGetting Started

• Create Windows Mobile database• New (empty) database

• New database with schema, but no data (for synchronization)

D l d t b t WM• Deploy database to WM

• Start database on WM

• Connect from desktop via ODBCConnect from desktop via ODBC

• Start developing using Visual Studio or PocketBuilder

• Debug and test

• Deploy application

Page 11: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Getting Started ‐ DemoGetting Started  Demo

• Creating and deploying a database to Windows Mobileg p y g• Create Database Wizard

• Deploy Synchronization Model Wizard

Page 12: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

SQL Anywhere for Windows Mobile  Server yOptions

• Start db server by launching dbsrv11 exe• Start db server by launching dbsrv11.exe– Complete server startup options– When connecting from desktop, use TCP/IP

• Auto‐start db from within your applicationAuto‐start db from within your application– Use a file data source

• Considerations– Database encryption using AES FIPS and AES256 FIPSDatabase encryption using AES_FIPS and AES256_FIPS  

algorithms– No personal db server, just network db server– Cannot run two db servers at the same time, but can 

l i l db i hrun multiple dbs in the same server– No support for db mirroring, external stored 

procedures, Java in the db, remote data access– By default, no ICU library is installedBy default, no ICU library is installed

Page 13: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

SQL Anywhere for Windows Mobile  Server O i ( )Options (cont.)

• File data source examplep• Use the DSN or the FILEDSN keyword is your connection string

• WM searches for the data source files in the root directory of the device (e g \filename dsn)device (e.g. \filename.dsn)

• Create file dsn on desktop, then transfer to Windows Mobile

[ODBC]uid=dbapwd=sqlenginename=demoenginename=demodatabasename=demodatabasefile=\My Documents\demo.dbstart=\Program Files\SQLAny11\dbsrv11.exe

Page 14: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Visual Studio DevelopmentVisual Studio Development

• Leading IDE for Windows Mobileg

• Create Smart Device project

• Deploy to WM emulator (test) vs. device (production)

• If using emulator…C A i S i D i E l ( dl ) b i k• Connect to ActiveSync via Device Emulator (cradle) to obtain network connection (TCP/IP)

• Install SQL Anywhere – same procedure as actual device

Page 15: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Programming InterfacesProgramming Interfaces

• .NET Compact Framework (ADO.NET)p ( )• Versions 2.0 and 3.5

• Develop using C#, VB.NET or C/C++

• SQL Anywhere NET data provider (iAnywhere Data SQLAnywhere dll)• SQL Anywhere .NET data provider (iAnywhere.Data.SQLAnywhere.dll)

• Other• ODBC

• Embedded SQL

Samples available with SA installationSamples available with SA installation

Page 16: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

SQL Anywhere .NET Data ProviderSQL Anywhere .NET Data Provider

Page 17: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Connecting to a DatabaseConnecting to a Database

• Make sure to add a reference to the SA (CE) assembly( ) y• C:\Program Files\SQL Anywhere 11\CE\Assembly\V2\iAnywhere.Data.SQLAnywhere.dll

i iA h D t SQLA husing iAnywhere.Data.SQLAnywhere;

SAConnection conn;

try{

conn = new SAConnection("Data Source=SQL Anywhere 11 Demo;UID=DBA;PWD=sql");

conn.Open();}}catch (SAException ex){

// Error handling}

conn.Close();

Page 18: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Accessing Records: SACommandAccessing Records: SACommand

• Recommended method to access data

• Used with SADataReader (retrieves one row at a time)

SACommand cmd = new SACommand("SELECT Surname FROM Employees", conn);

SADataReader reader = cmd.ExecuteReader();

// Populate list controllistEmployees.BeginUpdate();while (reader.Read()){{

listEmployees.Items.Add(reader.GetString(0));}listEmployees.EndUpdate();

d Cl ()reader.Close();

Page 19: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Accessing Records: SADataAdapterAccessing Records: SADataAdapter

• Retrieves entire result set in a DataSet

• DataSet is disconnected

DataSet ds = new DataSet();

SADataAdapter da = new SADataAdapter("SELECT Surname FROM Employees", conn);

da.Fill(ds, "Results");

dataGrid1.DataSource = ds.Tables["Results"];

Page 20: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Using Stored ProceduresUsing Stored Procedures

• ExecuteReader, ExecuteNonQuery, ExecuteScalar, Q y,

SACommand cmd = new SACommand("ShowProductInfo", conn);cmd.CommandType = CommandType.StoredProcedure;

// SACommand cmd = new SACommand("call ShowProductInfo(?)", conn);// cmd.CommandType = CommandType.Text;

SAParameter param = cmd.CreateParameter();param.SADbType = SADbType.Int32;param.Direction = ParameterDirection.Input;param.Value = 301;cmd.Parameters.Add(param);

SADataReader reader = cmd.ExecuteReader();reader.Read();int ID = reader.GetInt32(0);string name = reader.GetString(1);t i d i d G tSt i (2)string descrip = reader.GetString(2);

decimal price = reader.GetDecimal(6);

// SACommand cmd = new SACommand("call ShowProductInfo( 301 )", conn);

Page 21: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Changing Data

// Inserting rows

Changing Data

gSACommand insertCmd = new SACommand(

"INSERT INTO Departments( DepartmentID, DepartmentName ) VALUES( ?, ? )", conn );

SAParameter parm = new SAParameter();parm.SADbType = SADbType.Integer;i C d dd( )insertCmd.Parameters.Add(parm);parm = new SAParameter();parm.SADbType = SADbType.Char;insertCmd.Parameters.Add(parm);

insertCmd Parameters[0] Value = 600;insertCmd.Parameters[0].Value = 600;insertCmd.Parameters[1].Value = "Eastern Sales";int recordsAffected = insertCmd.ExecuteNonQuery();insertCmd.Parameters[0].Value = 700;insertCmd.Parameters[1].Value = "Western Sales";recordsAffected = insertCmd.ExecuteNonQuery();

// Updating rowsSACommand updateCmd = new SACommand(

"UPDATE Departments SET DepartmentName = 'Engineering' WHERE DepartmentID=100", conn );int recordsAffected = updateCmd.ExecuteNonQuery();

// Deleting rowsSACommand deleteCmd = new SACommand(

"DELETE FROM Departments WHERE ( DepartmentID > 500 )", conn);int recordsAffected = deleteCmd.ExecuteNonQuery();

Page 22: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Visual Studio Application ‐ DemoVisual Studio Application  Demo

Page 23: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Deploying the DatabaseDeploying the Database

• Database server binaries

• SQL Anywhere .NET Data Provider

• ODBC driver Depending on • Embedded SQL client files

• File data source

client interface

• Database file

• Script files – optional

• Encryption and TLS binaries optional• Encryption and TLS binaries – optional

Page 24: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Adding Synchronization with MobiLinkAdding Synchronization with MobiLink

• Create Synchronization Model Wizardy• Connect to backend and visually define synchronization logic

• No need to write synchronization scripts

D l S h i ti M d l Wi d• Deploy Synchronization Model Wizard• Automatically deploy sync logic to backend

• Automatically create new “sync‐ready” mobile database

• MobiLink synchronization server to handle sync requests

• MobiLink client invoked from Windows Mobile to trigger h i isynchronization

• Server‐initiated synchronization and messaging

Page 25: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

MobiLink Synchronization – DemoMobiLink Synchronization  Demo

WindowsMobileMobile

Page 26: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Security ConsiderationsSecurity Considerations

• Device theft or loss• 128‐bit encryption of the database

• No difference whether db is stored in main memory or external storage cardstorage card

• Interception of data transmission• 128‐bit encryption of client/server and MobiLink communication

• Unauthorized access to mobile device• Ensure only relevant data is downloaded to device

• Provide log in access via user name and password• Provide log in access via user name and password

• Device provisioning• Use systems management software such as Afaria

Page 27: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Additional ResourcesAdditional Resources

• Sybase.com/iAnywherey / y• Free SQL Anywhere Developer Edition

• Whitepapers and sample code

• Developer blogs• Developer blogs

• Other TechWave sessions• Developing Applications for SQL Anywhere using Visual Studio

• Synchronizing SQL Anywhere Databases in a .NET Environment

• Mobilizing ASE, Oracle and SQL Server Databases

• Afaria trackAfaria track

Page 28: DEVELOPING WINDOWS MOBILE APPLICATIONS · Why Develop Windows Mobile Database Ali i ?Applications? • Windows Mobile prevalent at the front lines of business • Some examples: sales

Questions?Questions?

Thank you!Thank you!