SlideShare a Scribd company logo
1 of 34
Builders & Developers
Workshop
SESSION 8
PREPARED & PRESENTED BY : MOATASIM MAGDY
Our topic today
Database
Why database ?
Queries
Create
Select
Insert
Update
Delete
Drop
Create Table
CREATE TABLE table_name
(
Column_name1 data_type(Size),
Column_name2 data_type(Size),
Column_name3 data_type(Size),
…….
);
Insert Query
INSERT INTO table_name
VALUES (value1, value2 , value3 …);
OR
INSERT INTO table_name
(column1, column2, column3 ….)
VALUES (value1, value2 , value3 …);
Select query
SELECT column_name, column_name2
FROM table_name
WHERE column_name operator value;
OR
SELECT *
FROM table_name
WHERE column_name operator value;
Operators
= Equal
<> Not equal
> Greater than
< Less than
>= Greater than
<= Less than
LIKE Search for pattern
Update query
UPDATE table_name
SET column1 = VALUE, column2 = VALUE
WHERE some_column = some_value;
Delete Query
DELETE FROM table_name
WHERE some_column = some_value;
Drop Table
DROP TABLE table_name
How to connect Your Universal
application with sqlite ?
Step 1
First press tools then open extensions and updates, make sure these
2 extensions are available.
Step 2
Then from solution explorer right
click on references from windows 8.1
part then select add reference.
Step 3
After you open reference manager in windows phone select this.
Step 4
Then from solution explorer right
click on references from windows
8.1 part then select add reference.
Step 5
After you open reference manager in windows phone select this.
Step 6
You will notice these warnings in
windows and windows phone
Step 7
To solve this warnings open
configuration manager from the
Debug in the top bar of visual
studio.
Step 8
Right click on the project from solution and explorer then open
“manage nugget packages” and search for sqlite-net then install.
Step 9
To make sure every thing is going
right you`ll notice appearance of
this 2 classes in windows and
windows phone part.
Connect your database with C#
Create Database.
Check existence of database.
Create Table , Create using database connection.
Add record(s) to your table
Select record from your table
Remove record from your table
Update record from your table
Drop table
Database
Open create if not existence
Check if not exist
Table
We start defining the class that
represent the table row ->
Then add the table
to the database
Add a record to a table
Add one record. Add more than one record
Select record from your table
SQLiteAsyncConnection conn = new SQLiteAsyncConnection("people.db");
var cityUsers = await conn.QueryAsync<User>(
"SELECT * FROM Users WHERE Name = ?", new object[] { textbox1.Text
});
foreach (var user in cityUsers)
{
UserList.ItemsSource = cityUsers;
}
Select all records
SQLiteAsyncConnection conn = new SQLiteAsyncConnection("people.db");
bool dbExist = await CheckDbAsync("people.db");
if (!dbExist)
{
await CreateDataBase();
}
var query = conn.Table<User>();
users = await query.ToListAsync();
UserList.ItemsSource = users;
Delete Record
private void Button_Click_5(object sender, RoutedEventArgs e)
{
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,
"people.db");
using (var db = new SQLite.SQLiteConnection(dbPath))
{ try
{ db.Execute("DELETE FROM Users WHERE Name = ?", textbox1.Text); }
catch (Exception ex)
{ // EXCEPTION HANDLING }}}
Update Record
private void Button_Click_6(object sender, RoutedEventArgs e)
{
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,
"people.db");
using (var db = new SQLite.SQLiteConnection(dbPath))
{ try
{ db.Execute("UPDATE Users SET Name = ? WHERE Name = ?", textbox2.Text,textbox1.Text);
}
catch (Exception ex)
{ // EXCEPTION HANDLING }}}
Drop Table
XAML: How to do list ?
<ListView x:Name="UserList" Margin="671,53,20,20">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Margin="10">
<TextBlock Text="{Binding Name}" />
<TextBlock Text="{Binding City}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Summary
Any questions ?
Thank you 

More Related Content

What's hot

CIS 336 Final Exam 2 (Devry)s
CIS 336 Final Exam 2 (Devry)sCIS 336 Final Exam 2 (Devry)s
CIS 336 Final Exam 2 (Devry)scritterc07
 
3. R- list and data frame
3. R- list and data frame3. R- list and data frame
3. R- list and data framekrishna singh
 
07.3. Android Alert message, List, Dropdown, and Auto Complete
07.3. Android Alert message, List, Dropdown, and Auto Complete07.3. Android Alert message, List, Dropdown, and Auto Complete
07.3. Android Alert message, List, Dropdown, and Auto CompleteOum Saokosal
 
Learning sql from w3schools
Learning sql from w3schoolsLearning sql from w3schools
Learning sql from w3schoolsfarhan516
 
Chetan postgresql partitioning
Chetan postgresql partitioningChetan postgresql partitioning
Chetan postgresql partitioningOpenSourceIndia
 
30 08 Final Sql
30 08 Final Sql30 08 Final Sql
30 08 Final Sqlsarov
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1Swapnali Pawar
 
Vtiger picklist 创建实例
Vtiger picklist 创建实例Vtiger picklist 创建实例
Vtiger picklist 创建实例YUCHENG HU
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive TechandMate
 
Data Preparation- handling missing value
Data Preparation- handling missing valueData Preparation- handling missing value
Data Preparation- handling missing valueRupak Roy
 

What's hot (20)

CIS 336 Final Exam 2 (Devry)s
CIS 336 Final Exam 2 (Devry)sCIS 336 Final Exam 2 (Devry)s
CIS 336 Final Exam 2 (Devry)s
 
Array operators
Array operatorsArray operators
Array operators
 
@Prompt
@Prompt@Prompt
@Prompt
 
MongoDB
MongoDBMongoDB
MongoDB
 
3. R- list and data frame
3. R- list and data frame3. R- list and data frame
3. R- list and data frame
 
Data manipulation language
Data manipulation languageData manipulation language
Data manipulation language
 
07.3. Android Alert message, List, Dropdown, and Auto Complete
07.3. Android Alert message, List, Dropdown, and Auto Complete07.3. Android Alert message, List, Dropdown, and Auto Complete
07.3. Android Alert message, List, Dropdown, and Auto Complete
 
Learning sql from w3schools
Learning sql from w3schoolsLearning sql from w3schools
Learning sql from w3schools
 
Correlated update vs merge
Correlated update vs mergeCorrelated update vs merge
Correlated update vs merge
 
Chetan postgresql partitioning
Chetan postgresql partitioningChetan postgresql partitioning
Chetan postgresql partitioning
 
Crash course in sql
Crash course in sqlCrash course in sql
Crash course in sql
 
Dbms lab Manual
Dbms lab ManualDbms lab Manual
Dbms lab Manual
 
30 08 Final Sql
30 08 Final Sql30 08 Final Sql
30 08 Final Sql
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
Radgrid
RadgridRadgrid
Radgrid
 
Vtiger picklist 创建实例
Vtiger picklist 创建实例Vtiger picklist 创建实例
Vtiger picklist 创建实例
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
Data Preparation- handling missing value
Data Preparation- handling missing valueData Preparation- handling missing value
Data Preparation- handling missing value
 
R factors
R   factorsR   factors
R factors
 

Viewers also liked

Session five Builders & developers workshop MSTC`15
Session five Builders & developers workshop MSTC`15Session five Builders & developers workshop MSTC`15
Session five Builders & developers workshop MSTC`15Moatasim Magdy
 
Session three Builders & developers workshop Microsoft Tech Club 2015
Session three Builders & developers workshop Microsoft Tech Club 2015Session three Builders & developers workshop Microsoft Tech Club 2015
Session three Builders & developers workshop Microsoft Tech Club 2015Moatasim Magdy
 
Session seven Builders & Developers workshop MSTC`15
Session seven Builders & Developers workshop MSTC`15Session seven Builders & Developers workshop MSTC`15
Session seven Builders & Developers workshop MSTC`15Moatasim Magdy
 
Session four introduction to XAML builders and developers workshop MSTCCU`15
Session four introduction to XAML builders and developers workshop MSTCCU`15Session four introduction to XAML builders and developers workshop MSTCCU`15
Session four introduction to XAML builders and developers workshop MSTCCU`15Moatasim Magdy
 
MSTCCU'16 - Aspiration Webbers - Session 1 - Introduction To ASP.net
MSTCCU'16 - Aspiration Webbers - Session 1 - Introduction To ASP.net MSTCCU'16 - Aspiration Webbers - Session 1 - Introduction To ASP.net
MSTCCU'16 - Aspiration Webbers - Session 1 - Introduction To ASP.net Moataz_Hesham
 
Builders and Developers Session one MSTC`15
Builders and Developers Session one MSTC`15Builders and Developers Session one MSTC`15
Builders and Developers Session one MSTC`15Moatasim Magdy
 
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...Wagdy Mohamed
 
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " First...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " First...Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " First...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " First...Wagdy Mohamed
 

Viewers also liked (8)

Session five Builders & developers workshop MSTC`15
Session five Builders & developers workshop MSTC`15Session five Builders & developers workshop MSTC`15
Session five Builders & developers workshop MSTC`15
 
Session three Builders & developers workshop Microsoft Tech Club 2015
Session three Builders & developers workshop Microsoft Tech Club 2015Session three Builders & developers workshop Microsoft Tech Club 2015
Session three Builders & developers workshop Microsoft Tech Club 2015
 
Session seven Builders & Developers workshop MSTC`15
Session seven Builders & Developers workshop MSTC`15Session seven Builders & Developers workshop MSTC`15
Session seven Builders & Developers workshop MSTC`15
 
Session four introduction to XAML builders and developers workshop MSTCCU`15
Session four introduction to XAML builders and developers workshop MSTCCU`15Session four introduction to XAML builders and developers workshop MSTCCU`15
Session four introduction to XAML builders and developers workshop MSTCCU`15
 
MSTCCU'16 - Aspiration Webbers - Session 1 - Introduction To ASP.net
MSTCCU'16 - Aspiration Webbers - Session 1 - Introduction To ASP.net MSTCCU'16 - Aspiration Webbers - Session 1 - Introduction To ASP.net
MSTCCU'16 - Aspiration Webbers - Session 1 - Introduction To ASP.net
 
Builders and Developers Session one MSTC`15
Builders and Developers Session one MSTC`15Builders and Developers Session one MSTC`15
Builders and Developers Session one MSTC`15
 
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " Sessi...
 
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " First...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " First...Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " First...
Microsoft Tech Club Cairo University "MSTC'16 Builders and Developers " First...
 

Similar to Session 8 connect your universal application with database .. builders & developers workshop MSTC15

Similar to Session 8 connect your universal application with database .. builders & developers workshop MSTC15 (20)

MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
 
Databases with SQLite3.pdf
Databases with SQLite3.pdfDatabases with SQLite3.pdf
Databases with SQLite3.pdf
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
 
Module 3
Module 3Module 3
Module 3
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
 
chapter 8 SQL.ppt
chapter 8 SQL.pptchapter 8 SQL.ppt
chapter 8 SQL.ppt
 
Sql wksht-2
Sql wksht-2Sql wksht-2
Sql wksht-2
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
 
DBMS LAB M.docx
DBMS LAB M.docxDBMS LAB M.docx
DBMS LAB M.docx
 
Introduction to Oracle Database.pptx
Introduction to Oracle Database.pptxIntroduction to Oracle Database.pptx
Introduction to Oracle Database.pptx
 
Database concepts
Database conceptsDatabase concepts
Database concepts
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinh
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
 
DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
 
MySQL.pptx comuterscience from kvsbbsrs.
MySQL.pptx comuterscience from kvsbbsrs.MySQL.pptx comuterscience from kvsbbsrs.
MySQL.pptx comuterscience from kvsbbsrs.
 
MySQL Basics
MySQL BasicsMySQL Basics
MySQL Basics
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

Session 8 connect your universal application with database .. builders & developers workshop MSTC15

  • 1. Builders & Developers Workshop SESSION 8 PREPARED & PRESENTED BY : MOATASIM MAGDY
  • 5. Create Table CREATE TABLE table_name ( Column_name1 data_type(Size), Column_name2 data_type(Size), Column_name3 data_type(Size), ……. );
  • 6. Insert Query INSERT INTO table_name VALUES (value1, value2 , value3 …); OR INSERT INTO table_name (column1, column2, column3 ….) VALUES (value1, value2 , value3 …);
  • 7. Select query SELECT column_name, column_name2 FROM table_name WHERE column_name operator value; OR SELECT * FROM table_name WHERE column_name operator value;
  • 8. Operators = Equal <> Not equal > Greater than < Less than >= Greater than <= Less than LIKE Search for pattern
  • 9. Update query UPDATE table_name SET column1 = VALUE, column2 = VALUE WHERE some_column = some_value;
  • 10. Delete Query DELETE FROM table_name WHERE some_column = some_value; Drop Table DROP TABLE table_name
  • 11. How to connect Your Universal application with sqlite ?
  • 12. Step 1 First press tools then open extensions and updates, make sure these 2 extensions are available.
  • 13. Step 2 Then from solution explorer right click on references from windows 8.1 part then select add reference.
  • 14. Step 3 After you open reference manager in windows phone select this.
  • 15. Step 4 Then from solution explorer right click on references from windows 8.1 part then select add reference.
  • 16. Step 5 After you open reference manager in windows phone select this.
  • 17. Step 6 You will notice these warnings in windows and windows phone
  • 18. Step 7 To solve this warnings open configuration manager from the Debug in the top bar of visual studio.
  • 19. Step 8 Right click on the project from solution and explorer then open “manage nugget packages” and search for sqlite-net then install.
  • 20. Step 9 To make sure every thing is going right you`ll notice appearance of this 2 classes in windows and windows phone part.
  • 21. Connect your database with C# Create Database. Check existence of database. Create Table , Create using database connection. Add record(s) to your table Select record from your table Remove record from your table Update record from your table Drop table
  • 22. Database Open create if not existence Check if not exist
  • 23. Table We start defining the class that represent the table row -> Then add the table to the database
  • 24. Add a record to a table Add one record. Add more than one record
  • 25. Select record from your table SQLiteAsyncConnection conn = new SQLiteAsyncConnection("people.db"); var cityUsers = await conn.QueryAsync<User>( "SELECT * FROM Users WHERE Name = ?", new object[] { textbox1.Text }); foreach (var user in cityUsers) { UserList.ItemsSource = cityUsers; }
  • 26. Select all records SQLiteAsyncConnection conn = new SQLiteAsyncConnection("people.db"); bool dbExist = await CheckDbAsync("people.db"); if (!dbExist) { await CreateDataBase(); } var query = conn.Table<User>(); users = await query.ToListAsync(); UserList.ItemsSource = users;
  • 27. Delete Record private void Button_Click_5(object sender, RoutedEventArgs e) { var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "people.db"); using (var db = new SQLite.SQLiteConnection(dbPath)) { try { db.Execute("DELETE FROM Users WHERE Name = ?", textbox1.Text); } catch (Exception ex) { // EXCEPTION HANDLING }}}
  • 28. Update Record private void Button_Click_6(object sender, RoutedEventArgs e) { var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "people.db"); using (var db = new SQLite.SQLiteConnection(dbPath)) { try { db.Execute("UPDATE Users SET Name = ? WHERE Name = ?", textbox2.Text,textbox1.Text); } catch (Exception ex) { // EXCEPTION HANDLING }}}
  • 30. XAML: How to do list ? <ListView x:Name="UserList" Margin="671,53,20,20"> <ListView.ItemTemplate> <DataTemplate> <StackPanel Margin="10"> <TextBlock Text="{Binding Name}" /> <TextBlock Text="{Binding City}" /> </StackPanel> </DataTemplate> </ListView.ItemTemplate> </ListView>
  • 31.