SlideShare a Scribd company logo
WinRT Apps
+ Silverlight
30 April 2014
Building Apps for Windows Phone 8.1 Jump Start
Complex Schema
ItemReferenceData
PK ItemId
ItemName
ItemDescription
FK1 CategoryId
Categories
PK CategoryId
CategoryName
Lists
PK ListId
ListName
ListItems
PK ListItemId
ListItemName
FK1 ListId
Quantity
Category
Description
FK2 StoreId
Stores
PK StoreId
StoreName
StoreLocationLat
StoreLocationLong
StoreAddressLine1
StoreAddressLine2
StoreAddressCity
StoreAddressState
StoreAddressCountry
StoryAddressZip
Favorites
PK FavoriteItemId
FavoriteItemName
FavoriteItemCategory
FavoriteItemQuantity
FavoriteItemDescription
FK1 FavoriteItemListId
FavoriteItemPhoto
History
PK HistoryItemId
HistoryItemName
HistoryItemCategory
HistoryItemQuantity
HistoryItemDescriptioin
HistoryItemDateAdded
FK1 HistoryItemListId
HistoryItemPhoto
Reference Data
Words
PK WordId
Word
Pronunciation
Definition
AlternateSpellings
Origin
Favorites
PK FavoriteId
FK1 WordId
History
PK HistoryItemId
FK1 WordId
AddedDate
using (var db = new SQLitePCL.Database("demo.db"))
{
db.Open();
using (var stmt = db.PrepareStatement
("SELECT name, age FROM people"))
{
while (stmt.Step())
{
var name = stmt.GetTextAt(0);
var age = stmt.GetIntAt(1);
}
}
}
var db =
new SQLite.SQLiteAsyncConnection(App.DBPath);
var _customer = await
(from c in db.Table<Customer>()
where c.Id == customerId
select c).FirstOrDefaultAsync();
if (customer != null)
{
var Id = _customer.Id;
var Name = _customer.Name;
}
http://bit.ly/Zxg2Ox
http://bit.ly/MuzL1e
http://bit.ly/130PpGa
private void LoadDatabase()
{
// Get a reference to the SQLite database
conn = new SQLiteConnection("sqlitepcldemo.db");
string sql = @"CREATE TABLE IF NOT EXISTS
Customer (Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
Name VARCHAR( 140 ),
City VARCHAR( 140 ),
Contact VARCHAR( 140 )
);";
using (var statement = conn.Prepare(sql))
{
statement.Step();
}
}
// SqlConnection was opened in App.xaml.cs and exposed through property conn
var db = App.conn;
try
{
using (var custstmt = db.Prepare("INSERT INTO Customer (Name, City, Contact) VALUES (?, ?, ?)"))
{
custstmt.Bind(1, customerName);
custstmt.Bind(2, customerCity);
custstmt.Bind(3, customerContact);
custstmt.Step();
}
}
catch (Exception ex)
{
// TODO: Handle error
}
public Customer GetCustomer(int customerId)
{
Customer customer = null;
using (var statement = dbconn.Prepare("SELECT Id, Name, City, Contact FROM Customer WHERE Id = ?"))
{
statement.Bind(1, customerId);
if (SQLiteResult.DONE == statement.Step())
{
customer = new Customer()
{
Id = (long)statement[0],
Name = (string)statement[1],
City = (string)statement[2],
Contact = (string)statement[3]
};
}
}
return customer;
}
// See if the customer already exists
var existingCustomer = GetCustomer(customer.Id);
if (existingCustomer != null)
{
using (var custstmt = dbconn.Prepare("UPDATE Customer SET Name = ?, City = ?, Contact = ? WHERE Id=?"))
{
// NOTE when using anonymous parameters the first has an index of 1, not 0.
custstmt.Bind(1, customer.Name);
custstmt.Bind(2, customer.City);
custstmt.Bind(3, customer.Contact);
custstmt.Bind(4, customer.Id);
custstmt.Step();
}
}
public void DeleteCustomer(int customerId)
{
using (var statement = dbconn.Prepare("DELETE FROM Customer WHERE Id = ?"))
{
statement.Bind(1, customerId);
statement.Step();
}
}
using (var statement = dbconn.Prepare("BEGIN TRANSACTION"))
{
statement.Step();
}
// Execute one or more statements…
using (var custstmt = dbconn.Prepare("INSERT INTO Customer (Name, City, Contact) VALUES (?, ?, ?)"))
{
...
}
using (var projstmt = dbconn.Prepare("INSERT INTO Project (Name, Title, DueDate, CustomerId) VALUES (?, ?, ?, ?)"))
{
...
}
// COMMIT to accept all changes or ROLLBACK TRANSACTION to discard pending changes
using (var statement = dbconn.Prepare(“COMMIT TRANSACTION"))
{
statement.Step();
}
Customer
PK Id
Name
City
Contact
Project
PK Id
Name
Description
DueDate
FK1 CustomerId
Project
PK Id
Name
Description
DueDate
FK1 CustomerId
Project
PK Id
Name
Description
DueDate
FK1 CustomerId
Customer
PK Id
Name
City
Contact
Project
PK Id
Name
Description
DueDate
FK1 CustomerId
Project
PK Id
Name
Description
DueDate
FK1 CustomerId
CREATE TABLE IF NOT EXISTS Project
(Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
CustomerId INTEGER,
Name VARCHAR( 140 ),
Description VARCHAR( 140 ),
DueDate DATETIME,
FOREIGN KEY(CustomerId) REFERENCES Customer(Id)
);
// Turn on Foreign Key constraints
sql = @"PRAGMA foreign_keys = ON";
using (var statement = dbconn.Prepare(sql))
{
statement.Step();
}
Type Description SQLiteWinRT
PRIMARY KEY Defines the column(s) of the primary key
- 1 per table max
Yes
In Column or Table definition in a
CREATE TABLE SQL statement
UNIQUE Column constraint enforces unique values
in that column
Yes
In Column definition
NOT NULL Column constraint prevents null values Yes
In Column definition
CHECK Column or Table constraint: constraint
expression is evaluated on every insert or
update, and if ‘0’ returned, constraint fails
Yes
In Column or Table definition
http://sqlite.org/lang_createtable.html
// Create index on Foreign Key column
sql = @"CREATE INDEX IF NOT EXISTS
fk_customer_project_idx
ON project (customerId) ASC";
using (var statement = dbconn.Prepare(sql))
{
statement.Step();
}
http://www.sqlite.org/cvstrac/wiki?p=ManagementTools
http://sqlitestudio.pl/
http://sqliteadmin.orbmu2k.de/
http://www.sqliteexpert.com/
©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the
U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft
must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after
the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related Content

What's hot

Csphtp1 18
Csphtp1 18Csphtp1 18
Csphtp1 18
HUST
 
comboboxentry - glade - ruby - guide
comboboxentry - glade - ruby - guidecomboboxentry - glade - ruby - guide
comboboxentry - glade - ruby - guideArulalan T
 
Ip project work test your knowledge
Ip project work test your knowledgeIp project work test your knowledge
Ip project work test your knowledge
KïShørê Choudhary
 
How to Define a KFF(key flex field) Step by Step
How to Define a KFF(key flex field) Step by StepHow to Define a KFF(key flex field) Step by Step
How to Define a KFF(key flex field) Step by Step
Pan Tian
 
Sql
SqlSql
A Window into Your Data: T-SQL Window Functions
A Window into Your Data: T-SQL Window FunctionsA Window into Your Data: T-SQL Window Functions
A Window into Your Data: T-SQL Window FunctionsSteve Hughes
 

What's hot (7)

Csphtp1 18
Csphtp1 18Csphtp1 18
Csphtp1 18
 
comboboxentry - glade - ruby - guide
comboboxentry - glade - ruby - guidecomboboxentry - glade - ruby - guide
comboboxentry - glade - ruby - guide
 
Ip project work test your knowledge
Ip project work test your knowledgeIp project work test your knowledge
Ip project work test your knowledge
 
How to Define a KFF(key flex field) Step by Step
How to Define a KFF(key flex field) Step by StepHow to Define a KFF(key flex field) Step by Step
How to Define a KFF(key flex field) Step by Step
 
Sql
SqlSql
Sql
 
A Window into Your Data: T-SQL Window Functions
A Window into Your Data: T-SQL Window FunctionsA Window into Your Data: T-SQL Window Functions
A Window into Your Data: T-SQL Window Functions
 
Qtp day 3
Qtp day 3Qtp day 3
Qtp day 3
 

Viewers also liked

04 lists and lists items in windows runtime apps
04   lists and lists items in windows runtime apps04   lists and lists items in windows runtime apps
04 lists and lists items in windows runtime apps
WindowsPhoneRocks
 
03 page navigation and data binding in windows runtime apps
03   page navigation and data binding in windows runtime apps03   page navigation and data binding in windows runtime apps
03 page navigation and data binding in windows runtime apps
WindowsPhoneRocks
 
21 app packaging, monetization and publication
21   app packaging, monetization and publication21   app packaging, monetization and publication
21 app packaging, monetization and publication
WindowsPhoneRocks
 
20 tooling and diagnostics
20   tooling and diagnostics20   tooling and diagnostics
20 tooling and diagnostics
WindowsPhoneRocks
 
16 interacting with user data contacts and appointments
16   interacting with user data contacts and appointments16   interacting with user data contacts and appointments
16 interacting with user data contacts and appointments
WindowsPhoneRocks
 
22 universal apps for windows
22   universal apps for windows22   universal apps for windows
22 universal apps for windows
WindowsPhoneRocks
 
23 silverlight apps on windows phone 8.1
23   silverlight apps on windows phone 8.123   silverlight apps on windows phone 8.1
23 silverlight apps on windows phone 8.1
WindowsPhoneRocks
 

Viewers also liked (8)

04 lists and lists items in windows runtime apps
04   lists and lists items in windows runtime apps04   lists and lists items in windows runtime apps
04 lists and lists items in windows runtime apps
 
3 554
3 5543 554
3 554
 
03 page navigation and data binding in windows runtime apps
03   page navigation and data binding in windows runtime apps03   page navigation and data binding in windows runtime apps
03 page navigation and data binding in windows runtime apps
 
21 app packaging, monetization and publication
21   app packaging, monetization and publication21   app packaging, monetization and publication
21 app packaging, monetization and publication
 
20 tooling and diagnostics
20   tooling and diagnostics20   tooling and diagnostics
20 tooling and diagnostics
 
16 interacting with user data contacts and appointments
16   interacting with user data contacts and appointments16   interacting with user data contacts and appointments
16 interacting with user data contacts and appointments
 
22 universal apps for windows
22   universal apps for windows22   universal apps for windows
22 universal apps for windows
 
23 silverlight apps on windows phone 8.1
23   silverlight apps on windows phone 8.123   silverlight apps on windows phone 8.1
23 silverlight apps on windows phone 8.1
 

Similar to 19 programming sq lite on windows phone 8.1

Lerman Vvs14 Ef Tips And Tricks
Lerman Vvs14  Ef Tips And TricksLerman Vvs14  Ef Tips And Tricks
Lerman Vvs14 Ef Tips And Tricks
Julie Lerman
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIRPeter Elst
 
10.Local Database & LINQ
10.Local Database & LINQ10.Local Database & LINQ
10.Local Database & LINQ
Nguyen Tuan
 
Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#
Vagif Abilov
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIR
Peter Elst
 
Going Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21cGoing Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21c
Jim Czuprynski
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008Luis Enrique
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commandsleminhvuong
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commandsphanleson
 
Sqlapi0.1
Sqlapi0.1Sqlapi0.1
Sqlapi0.1
jitendral
 
IBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesIBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql Features
Keshav Murthy
 
Enrique Amodeo | Graphql + Microservices = Win! | Codemotion Madrid 2018
Enrique Amodeo | Graphql + Microservices = Win! | Codemotion Madrid 2018 Enrique Amodeo | Graphql + Microservices = Win! | Codemotion Madrid 2018
Enrique Amodeo | Graphql + Microservices = Win! | Codemotion Madrid 2018
Codemotion
 
SQL for Web APIs - Simplifying Data Access for API Consumers
SQL for Web APIs - Simplifying Data Access for API ConsumersSQL for Web APIs - Simplifying Data Access for API Consumers
SQL for Web APIs - Simplifying Data Access for API Consumers
Jerod Johnson
 
JPA 2.0
JPA 2.0JPA 2.0
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateKiev ALT.NET
 
10 wp7 local database
10 wp7   local database10 wp7   local database
10 wp7 local databaseTao Wang
 
Windows Phone 8 - 7 Local Database
Windows Phone 8 - 7 Local DatabaseWindows Phone 8 - 7 Local Database
Windows Phone 8 - 7 Local DatabaseOliver Scheer
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
Richard Dingwall
 

Similar to 19 programming sq lite on windows phone 8.1 (20)

Lerman Vvs14 Ef Tips And Tricks
Lerman Vvs14  Ef Tips And TricksLerman Vvs14  Ef Tips And Tricks
Lerman Vvs14 Ef Tips And Tricks
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIR
 
10.Local Database & LINQ
10.Local Database & LINQ10.Local Database & LINQ
10.Local Database & LINQ
 
Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#Typed? Dynamic? Both! Cross-platform DSLs in C#
Typed? Dynamic? Both! Cross-platform DSLs in C#
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIR
 
Going Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21cGoing Native: Leveraging the New JSON Native Datatype in Oracle 21c
Going Native: Leveraging the New JSON Native Datatype in Oracle 21c
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
 
Executing Sql Commands
Executing Sql CommandsExecuting Sql Commands
Executing Sql Commands
 
Sqlapi0.1
Sqlapi0.1Sqlapi0.1
Sqlapi0.1
 
IBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesIBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql Features
 
Sql injection
Sql injectionSql injection
Sql injection
 
Enrique Amodeo | Graphql + Microservices = Win! | Codemotion Madrid 2018
Enrique Amodeo | Graphql + Microservices = Win! | Codemotion Madrid 2018 Enrique Amodeo | Graphql + Microservices = Win! | Codemotion Madrid 2018
Enrique Amodeo | Graphql + Microservices = Win! | Codemotion Madrid 2018
 
SQL for Web APIs - Simplifying Data Access for API Consumers
SQL for Web APIs - Simplifying Data Access for API ConsumersSQL for Web APIs - Simplifying Data Access for API Consumers
SQL for Web APIs - Simplifying Data Access for API Consumers
 
JPA 2.0
JPA 2.0JPA 2.0
JPA 2.0
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
 
10 wp7 local database
10 wp7   local database10 wp7   local database
10 wp7 local database
 
Windows Phone 8 - 7 Local Database
Windows Phone 8 - 7 Local DatabaseWindows Phone 8 - 7 Local Database
Windows Phone 8 - 7 Local Database
 
B_110500002
B_110500002B_110500002
B_110500002
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 

More from WindowsPhoneRocks

17 camera, media, and audio in windows phone 8.1
17   camera, media, and audio in windows phone 8.117   camera, media, and audio in windows phone 8.1
17 camera, media, and audio in windows phone 8.1
WindowsPhoneRocks
 
15 sensors and proximity nfc and bluetooth
15   sensors and proximity nfc and bluetooth15   sensors and proximity nfc and bluetooth
15 sensors and proximity nfc and bluetooth
WindowsPhoneRocks
 
14 tiles, notifications, and action center
14   tiles, notifications, and action center14   tiles, notifications, and action center
14 tiles, notifications, and action center
WindowsPhoneRocks
 
13 networking, mobile services, and authentication
13   networking, mobile services, and authentication13   networking, mobile services, and authentication
13 networking, mobile services, and authentication
WindowsPhoneRocks
 
12 maps, geolocation, and geofencing
12   maps, geolocation, and geofencing12   maps, geolocation, and geofencing
12 maps, geolocation, and geofencing
WindowsPhoneRocks
 
11 background tasks and multitasking
11   background tasks and multitasking11   background tasks and multitasking
11 background tasks and multitasking
WindowsPhoneRocks
 
10 sharing files and data in windows phone 8
10   sharing files and data in windows phone 810   sharing files and data in windows phone 8
10 sharing files and data in windows phone 8
WindowsPhoneRocks
 
09 data storage, backup and roaming
09   data storage, backup and roaming09   data storage, backup and roaming
09 data storage, backup and roaming
WindowsPhoneRocks
 
08 localization and globalization in windows runtime apps
08   localization and globalization in windows runtime apps08   localization and globalization in windows runtime apps
08 localization and globalization in windows runtime apps
WindowsPhoneRocks
 
07 windows runtime app lifecycle
07   windows runtime app lifecycle07   windows runtime app lifecycle
07 windows runtime app lifecycle
WindowsPhoneRocks
 
05 programming page controls and page transitions animations
05   programming page controls and page transitions animations05   programming page controls and page transitions animations
05 programming page controls and page transitions animations
WindowsPhoneRocks
 
02 getting started building windows runtime apps
02   getting started building windows runtime apps02   getting started building windows runtime apps
02 getting started building windows runtime apps
WindowsPhoneRocks
 
01 introducing the windows phone 8.1
01   introducing the windows phone 8.101   introducing the windows phone 8.1
01 introducing the windows phone 8.1
WindowsPhoneRocks
 
18 windows phone 8.1 for the enterprise developer
18   windows phone 8.1 for the enterprise developer18   windows phone 8.1 for the enterprise developer
18 windows phone 8.1 for the enterprise developer
WindowsPhoneRocks
 

More from WindowsPhoneRocks (14)

17 camera, media, and audio in windows phone 8.1
17   camera, media, and audio in windows phone 8.117   camera, media, and audio in windows phone 8.1
17 camera, media, and audio in windows phone 8.1
 
15 sensors and proximity nfc and bluetooth
15   sensors and proximity nfc and bluetooth15   sensors and proximity nfc and bluetooth
15 sensors and proximity nfc and bluetooth
 
14 tiles, notifications, and action center
14   tiles, notifications, and action center14   tiles, notifications, and action center
14 tiles, notifications, and action center
 
13 networking, mobile services, and authentication
13   networking, mobile services, and authentication13   networking, mobile services, and authentication
13 networking, mobile services, and authentication
 
12 maps, geolocation, and geofencing
12   maps, geolocation, and geofencing12   maps, geolocation, and geofencing
12 maps, geolocation, and geofencing
 
11 background tasks and multitasking
11   background tasks and multitasking11   background tasks and multitasking
11 background tasks and multitasking
 
10 sharing files and data in windows phone 8
10   sharing files and data in windows phone 810   sharing files and data in windows phone 8
10 sharing files and data in windows phone 8
 
09 data storage, backup and roaming
09   data storage, backup and roaming09   data storage, backup and roaming
09 data storage, backup and roaming
 
08 localization and globalization in windows runtime apps
08   localization and globalization in windows runtime apps08   localization and globalization in windows runtime apps
08 localization and globalization in windows runtime apps
 
07 windows runtime app lifecycle
07   windows runtime app lifecycle07   windows runtime app lifecycle
07 windows runtime app lifecycle
 
05 programming page controls and page transitions animations
05   programming page controls and page transitions animations05   programming page controls and page transitions animations
05 programming page controls and page transitions animations
 
02 getting started building windows runtime apps
02   getting started building windows runtime apps02   getting started building windows runtime apps
02 getting started building windows runtime apps
 
01 introducing the windows phone 8.1
01   introducing the windows phone 8.101   introducing the windows phone 8.1
01 introducing the windows phone 8.1
 
18 windows phone 8.1 for the enterprise developer
18   windows phone 8.1 for the enterprise developer18   windows phone 8.1 for the enterprise developer
18 windows phone 8.1 for the enterprise developer
 

Recently uploaded

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 

Recently uploaded (20)

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 

19 programming sq lite on windows phone 8.1

  • 1. WinRT Apps + Silverlight 30 April 2014 Building Apps for Windows Phone 8.1 Jump Start
  • 2. Complex Schema ItemReferenceData PK ItemId ItemName ItemDescription FK1 CategoryId Categories PK CategoryId CategoryName Lists PK ListId ListName ListItems PK ListItemId ListItemName FK1 ListId Quantity Category Description FK2 StoreId Stores PK StoreId StoreName StoreLocationLat StoreLocationLong StoreAddressLine1 StoreAddressLine2 StoreAddressCity StoreAddressState StoreAddressCountry StoryAddressZip Favorites PK FavoriteItemId FavoriteItemName FavoriteItemCategory FavoriteItemQuantity FavoriteItemDescription FK1 FavoriteItemListId FavoriteItemPhoto History PK HistoryItemId HistoryItemName HistoryItemCategory HistoryItemQuantity HistoryItemDescriptioin HistoryItemDateAdded FK1 HistoryItemListId HistoryItemPhoto
  • 3. Reference Data Words PK WordId Word Pronunciation Definition AlternateSpellings Origin Favorites PK FavoriteId FK1 WordId History PK HistoryItemId FK1 WordId AddedDate
  • 4.
  • 5.
  • 6.
  • 7. using (var db = new SQLitePCL.Database("demo.db")) { db.Open(); using (var stmt = db.PrepareStatement ("SELECT name, age FROM people")) { while (stmt.Step()) { var name = stmt.GetTextAt(0); var age = stmt.GetIntAt(1); } } } var db = new SQLite.SQLiteAsyncConnection(App.DBPath); var _customer = await (from c in db.Table<Customer>() where c.Id == customerId select c).FirstOrDefaultAsync(); if (customer != null) { var Id = _customer.Id; var Name = _customer.Name; }
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. private void LoadDatabase() { // Get a reference to the SQLite database conn = new SQLiteConnection("sqlitepcldemo.db"); string sql = @"CREATE TABLE IF NOT EXISTS Customer (Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, Name VARCHAR( 140 ), City VARCHAR( 140 ), Contact VARCHAR( 140 ) );"; using (var statement = conn.Prepare(sql)) { statement.Step(); } }
  • 14. // SqlConnection was opened in App.xaml.cs and exposed through property conn var db = App.conn; try { using (var custstmt = db.Prepare("INSERT INTO Customer (Name, City, Contact) VALUES (?, ?, ?)")) { custstmt.Bind(1, customerName); custstmt.Bind(2, customerCity); custstmt.Bind(3, customerContact); custstmt.Step(); } } catch (Exception ex) { // TODO: Handle error }
  • 15. public Customer GetCustomer(int customerId) { Customer customer = null; using (var statement = dbconn.Prepare("SELECT Id, Name, City, Contact FROM Customer WHERE Id = ?")) { statement.Bind(1, customerId); if (SQLiteResult.DONE == statement.Step()) { customer = new Customer() { Id = (long)statement[0], Name = (string)statement[1], City = (string)statement[2], Contact = (string)statement[3] }; } } return customer; }
  • 16. // See if the customer already exists var existingCustomer = GetCustomer(customer.Id); if (existingCustomer != null) { using (var custstmt = dbconn.Prepare("UPDATE Customer SET Name = ?, City = ?, Contact = ? WHERE Id=?")) { // NOTE when using anonymous parameters the first has an index of 1, not 0. custstmt.Bind(1, customer.Name); custstmt.Bind(2, customer.City); custstmt.Bind(3, customer.Contact); custstmt.Bind(4, customer.Id); custstmt.Step(); } }
  • 17. public void DeleteCustomer(int customerId) { using (var statement = dbconn.Prepare("DELETE FROM Customer WHERE Id = ?")) { statement.Bind(1, customerId); statement.Step(); } }
  • 18.
  • 19.
  • 20.
  • 21. using (var statement = dbconn.Prepare("BEGIN TRANSACTION")) { statement.Step(); } // Execute one or more statements… using (var custstmt = dbconn.Prepare("INSERT INTO Customer (Name, City, Contact) VALUES (?, ?, ?)")) { ... } using (var projstmt = dbconn.Prepare("INSERT INTO Project (Name, Title, DueDate, CustomerId) VALUES (?, ?, ?, ?)")) { ... } // COMMIT to accept all changes or ROLLBACK TRANSACTION to discard pending changes using (var statement = dbconn.Prepare(“COMMIT TRANSACTION")) { statement.Step(); }
  • 22. Customer PK Id Name City Contact Project PK Id Name Description DueDate FK1 CustomerId Project PK Id Name Description DueDate FK1 CustomerId Project PK Id Name Description DueDate FK1 CustomerId Customer PK Id Name City Contact Project PK Id Name Description DueDate FK1 CustomerId Project PK Id Name Description DueDate FK1 CustomerId
  • 23. CREATE TABLE IF NOT EXISTS Project (Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, CustomerId INTEGER, Name VARCHAR( 140 ), Description VARCHAR( 140 ), DueDate DATETIME, FOREIGN KEY(CustomerId) REFERENCES Customer(Id) );
  • 24. // Turn on Foreign Key constraints sql = @"PRAGMA foreign_keys = ON"; using (var statement = dbconn.Prepare(sql)) { statement.Step(); }
  • 25. Type Description SQLiteWinRT PRIMARY KEY Defines the column(s) of the primary key - 1 per table max Yes In Column or Table definition in a CREATE TABLE SQL statement UNIQUE Column constraint enforces unique values in that column Yes In Column definition NOT NULL Column constraint prevents null values Yes In Column definition CHECK Column or Table constraint: constraint expression is evaluated on every insert or update, and if ‘0’ returned, constraint fails Yes In Column or Table definition http://sqlite.org/lang_createtable.html
  • 26.
  • 27. // Create index on Foreign Key column sql = @"CREATE INDEX IF NOT EXISTS fk_customer_project_idx ON project (customerId) ASC"; using (var statement = dbconn.Prepare(sql)) { statement.Step(); }
  • 28.
  • 29.
  • 30.
  • 32.
  • 33.
  • 34.
  • 35. ©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.