SlideShare a Scribd company logo
Prepared by
ENG SOON CHEAH
Microsoft MVP
Install SQLite-UAP extensions form NuGet Package Manager
Next Install SQLite.Net-PCL extension from NuGet Package
• Include 4 functions CRUD Operations
• Bind data to a ListBox
<Grid Background="#FFF589E2">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Button x:Name="CreateDBbutton" Grid.Row="0" Content="Create Local Database" HorizontalAlignment="Center"
VerticalAlignment="Top" Click="button_Click" />
<Button x:Name="create" Grid.Row="1" Content="Create New Students" HorizontalAlignment="Center" Click="creat
e_Click"></Button>
<Button x:Name="read" Grid.Row="2" Content="Read Students List" Width="300" Click="read_Click" HorizontalAlig
nment="Center"></Button>
<Button x:Name="update" Grid.Row="3" Content="Update Details" Width="300" Click="update_Click" HorizontalAli
gnment="Stretch"></Button>
<ListView x:Name="allstudents" HorizontalAlignment="Stretch" Grid.Row="4">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock x:Name="ee" Text="{Binding Name}" FontSize="14"></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
public class Students
{
[SQLite.Net.Attributes.PrimaryKey, SQLite.Net.Attributes.AutoIncrement]
public int Id
{
get;
set;
}
public string Name
{
get;
set;
}
public string Address
{
get;
set;
}
public string Mobile
{
get;
set;
}
public Students()
{}
public Students(string name, string address, string mobile)
{
Name = name;
Address = address;
Mobile = mobile;
}
}
public static void CreateDatabase()
{
var sqlpath = System.IO.Path.Combine(Windows.Stora
ge.ApplicationData.Current.LocalFolder.Path, "Studentdb.
sqlite");
using(SQLite.Net.SQLiteConnection conn = new SQLit
e.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.
SQLitePlatformWinRT(), sqlpath))
{
conn.CreateTable < Students > ();
}
}
public void Insert(Students objContact)
{
var sqlpath = System.IO.Path.Combine(Windows.Storage.Appli
cationData.Current.LocalFolder.Path, "Studentdb.sqlite");
using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.S
QLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatform
WinRT(), sqlpath))
{
conn.RunInTransaction(() =>
{
conn.Insert(objContact);
});
}
}
// Retrieve the specific contact from the database.
public Students ReadContact(int contactid)
{
var sqlpath = System.IO.Path.Combine(Windows.Storage.Appli
cationData.Current.LocalFolder.Path, "Studentdb.sqlite");
using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.S
QLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatform
WinRT(), sqlpath))
{
var existingconact = conn.Query < Students > ("select * fro
m Students where Id =" + contactid).FirstOrDefault();
return existingconact;
}
}
//Read All Student details
public ObservableCollection < Students > ReadAllStudents()
{
var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Cur
rent.LocalFolder.Path, "Studentdb.sqlite");
using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnectio
n(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath))
{
List < Students > myCollection = conn.Table < Students > ().ToList < Stud
ents > ();
ObservableCollection < Students > StudentsList = new ObservableCollecti
on < Students > (myCollection);
return StudentsList;
}
}
//Update student detaisl
public void UpdateDetails(string name)
{
var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Student
db.sqlite");
using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.Win
RT.SQLitePlatformWinRT(), sqlpath))
{
var existingconact = conn.Query < Students > ("select * from Students where Name =" + name).FirstOrDe
fault();
if (existingconact != null)
{
existingconact.Name = name;
existingconact.Address = "NewAddress";
existingconact.Mobile = "962623233";
conn.RunInTransaction(() =>
{
conn.Update(existingconact);
});
}
}
}
//Delete all student or delete student table
public void DeleteAllContact()
{
var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Studentdb.sqlite");
using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformW
inRT(), sqlpath))
{
conn.DropTable < Students > ();
conn.CreateTable < Students > ();
conn.Dispose();
conn.Close();
}
}
Delete specific student
//Delete specific student
public void DeleteContact(int Id)
{
var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Studentdb.sqlite");
using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformW
inRT(), sqlpath))
{
var existingconact = conn.Query < Students > ("select * from Studentdb where Id =" + Id).FirstOrDefault();
if (existingconact != null)
{
conn.RunInTransaction(() =>
{
conn.Delete(existingconact);
});
}
}
}
• Local Data Base SQLite for Windows 10
https://code.msdn.microsoft.com/Local-
Data-Base-SQLite-for-5e6146aa

More Related Content

PPTX
Web Technologies - forms and actions
Aren Zomorodian
 
PPTX
Html web sql database
AbhishekMondal42
 
PPTX
Connecting and using PostgreSQL database with psycopg2 [Python 2.7]
Dinesh Neupane
 
ODP
Indexed db
Martin Giger
 
PPTX
Jdbc Java Programming
chhaichivon
 
PDF
09.Local Database Files and Storage on WP
Nguyen Tuan
 
PDF
Local data storage for mobile apps
Ivano Malavolta
 
PDF
Ajax chap 2.-part 1
Mukesh Tekwani
 
Web Technologies - forms and actions
Aren Zomorodian
 
Html web sql database
AbhishekMondal42
 
Connecting and using PostgreSQL database with psycopg2 [Python 2.7]
Dinesh Neupane
 
Indexed db
Martin Giger
 
Jdbc Java Programming
chhaichivon
 
09.Local Database Files and Storage on WP
Nguyen Tuan
 
Local data storage for mobile apps
Ivano Malavolta
 
Ajax chap 2.-part 1
Mukesh Tekwani
 

What's hot (18)

PDF
Ajax chap 3
Mukesh Tekwani
 
ODP
Sql lite android
Dushyant Nasit
 
PDF
Android datastorage
Krazy Koder
 
PDF
The Ring programming language version 1.5.3 book - Part 28 of 184
Mahmoud Samir Fayed
 
PDF
Local Storage
Ivano Malavolta
 
PPTX
Sequelize
Tarek Raihan
 
PPT
SQLITE Android
Sourabh Sahu
 
PPTX
Database connectivity in python
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Кирилл Латыш "ERP on Websockets"
Fwdays
 
PPTX
บทที่ 4 การเพิ่มข้อมูลลงฐานข้อมูล
Priew Chakrit
 
PPTX
Slick: Bringing Scala’s Powerful Features to Your Database Access
Rebecca Grenier
 
PDF
Hibernate Tutorial
Syed Shahul
 
PDF
22jdbc
Adil Jafri
 
PPT
Jdbc oracle
yazidds2
 
DOCX
Accessing data with android cursors
info_zybotech
 
PDF
REST Basics
Ivano Malavolta
 
PDF
DIY Percolator
jdhok
 
Ajax chap 3
Mukesh Tekwani
 
Sql lite android
Dushyant Nasit
 
Android datastorage
Krazy Koder
 
The Ring programming language version 1.5.3 book - Part 28 of 184
Mahmoud Samir Fayed
 
Local Storage
Ivano Malavolta
 
Sequelize
Tarek Raihan
 
SQLITE Android
Sourabh Sahu
 
Database connectivity in python
baabtra.com - No. 1 supplier of quality freshers
 
Кирилл Латыш "ERP on Websockets"
Fwdays
 
บทที่ 4 การเพิ่มข้อมูลลงฐานข้อมูล
Priew Chakrit
 
Slick: Bringing Scala’s Powerful Features to Your Database Access
Rebecca Grenier
 
Hibernate Tutorial
Syed Shahul
 
22jdbc
Adil Jafri
 
Jdbc oracle
yazidds2
 
Accessing data with android cursors
info_zybotech
 
REST Basics
Ivano Malavolta
 
DIY Percolator
jdhok
 
Ad

Viewers also liked (15)

PPTX
Windows 10 (UWP) App Development
Cheah Eng Soon
 
PDF
Introduction to universal windows platform(uwp) app development
Thilina Wijerathne
 
KEY
Social media 1 introduction
Donald Young
 
PPT
Slide
tmalloy1
 
PDF
Lobbying Rules Nonprofits
Tate Tryon CPAs
 
PPTX
Nt Cadcam Powerpoint For Linked In
m4ttyj17
 
ODT
Place Value Curriculum Map (published version)
Becky Kimball
 
PPTX
Lady gaga vs Katy Perry 2013
Maru Romano
 
PDF
IILIV_M4C4 Lezione 5. lavoro di rete e docente specializzato
raffaelebruno1
 
PDF
Mulheres na CI&T e o desafio das duas mil
Marilia Honorio
 
PPTX
Repaso de para empezar
larrylayfield
 
PPSX
Naatal14
Carlos Jorge
 
PDF
12 prerada voca i grozdja
Lelita Sanches
 
PDF
Adafruit raspberry-pi-lesson-9-controlling-a-dc-motor
Stefan Oprea
 
PPTX
Сучасна бібліотека на захисті прав молоді: проект Великоолександрівської цент...
Irina Taradyamenko
 
Windows 10 (UWP) App Development
Cheah Eng Soon
 
Introduction to universal windows platform(uwp) app development
Thilina Wijerathne
 
Social media 1 introduction
Donald Young
 
Slide
tmalloy1
 
Lobbying Rules Nonprofits
Tate Tryon CPAs
 
Nt Cadcam Powerpoint For Linked In
m4ttyj17
 
Place Value Curriculum Map (published version)
Becky Kimball
 
Lady gaga vs Katy Perry 2013
Maru Romano
 
IILIV_M4C4 Lezione 5. lavoro di rete e docente specializzato
raffaelebruno1
 
Mulheres na CI&T e o desafio das duas mil
Marilia Honorio
 
Repaso de para empezar
larrylayfield
 
Naatal14
Carlos Jorge
 
12 prerada voca i grozdja
Lelita Sanches
 
Adafruit raspberry-pi-lesson-9-controlling-a-dc-motor
Stefan Oprea
 
Сучасна бібліотека на захисті прав молоді: проект Великоолександрівської цент...
Irina Taradyamenko
 
Ad

Similar to SQLite with UWP (20)

PDF
SQLite Database Tutorial In Android
Android 5
 
PPTX
37c
Sireesh K
 
PPTX
Session 8 connect your universal application with database .. builders & deve...
Moatasim Magdy
 
PDF
How to Create Database component -Enterprise Application Using C# Lab
priya Nithya
 
PDF
ADO DOT NET
Salman Mushtaq
 
PDF
Part 3 binding navigator vb.net
Girija Muscut
 
PPT
Linq
Foyzul Karim
 
PDF
10.Local Database & LINQ
Nguyen Tuan
 
PPTX
Windows ストアーアプリで SQLite を使ってみよう
ShinichiAoyagi
 
PDF
04 connect-db-tools
Warawut
 
PPTX
Unit - IV (1).pptx
VaishnaviGaikwad67
 
PPTX
Unit - IV.pptx
VaishnaviGaikwad67
 
DOCX
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
PPTX
19 programming sq lite on windows phone 8.1
WindowsPhoneRocks
 
KEY
WPF: Working with Data
LearnNowOnline
 
PPTX
09.1. Android - Local Database (Sqlite)
Oum Saokosal
 
PPTX
76.pptx ajx ppt file for univercity of granted
hectortrading693
 
PPT
WPF and Databases
Doncho Minkov
 
PDF
Mvc4 crud operations.-kemuning senja
alifha12
 
PPTX
Android Database Tutorial
Perfect APK
 
SQLite Database Tutorial In Android
Android 5
 
Session 8 connect your universal application with database .. builders & deve...
Moatasim Magdy
 
How to Create Database component -Enterprise Application Using C# Lab
priya Nithya
 
ADO DOT NET
Salman Mushtaq
 
Part 3 binding navigator vb.net
Girija Muscut
 
10.Local Database & LINQ
Nguyen Tuan
 
Windows ストアーアプリで SQLite を使ってみよう
ShinichiAoyagi
 
04 connect-db-tools
Warawut
 
Unit - IV (1).pptx
VaishnaviGaikwad67
 
Unit - IV.pptx
VaishnaviGaikwad67
 
ANDROID USING SQLITE DATABASE ADMINISTRATORS ~HMFTJ
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
19 programming sq lite on windows phone 8.1
WindowsPhoneRocks
 
WPF: Working with Data
LearnNowOnline
 
09.1. Android - Local Database (Sqlite)
Oum Saokosal
 
76.pptx ajx ppt file for univercity of granted
hectortrading693
 
WPF and Databases
Doncho Minkov
 
Mvc4 crud operations.-kemuning senja
alifha12
 
Android Database Tutorial
Perfect APK
 

More from Cheah Eng Soon (20)

PPTX
Microsoft Defender for Endpoint
Cheah Eng Soon
 
PPTX
Azure Active Directory - Secure and Govern
Cheah Eng Soon
 
PPTX
Microsoft Zero Trust
Cheah Eng Soon
 
PPTX
MEM for OnPrem Environments
Cheah Eng Soon
 
PPTX
Microsoft Threat Protection Automated Incident Response
Cheah Eng Soon
 
PDF
Azure Penetration Testing
Cheah Eng Soon
 
PDF
Azure Penetration Testing
Cheah Eng Soon
 
PPTX
Microsoft Threat Protection Automated Incident Response Demo
Cheah Eng Soon
 
PPTX
Microsoft Secure Score Demo
Cheah Eng Soon
 
PPTX
Microsoft Cloud App Security Demo
Cheah Eng Soon
 
PPTX
M365 Attack Simulation Demo
Cheah Eng Soon
 
PPTX
Cloud Security Demo
Cheah Eng Soon
 
PPTX
Azure Active Directory - External Identities Demo
Cheah Eng Soon
 
PPTX
Azure WAF
Cheah Eng Soon
 
PPTX
Azure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Cheah Eng Soon
 
PPTX
Microsoft Azure的20大常见安全漏洞与配置错误
Cheah Eng Soon
 
PDF
20 common security vulnerabilities and misconfiguration in Azure
Cheah Eng Soon
 
PPTX
Integrate Microsoft Graph with Azure Bot Services
Cheah Eng Soon
 
PPTX
Azure Sentinel with Office 365
Cheah Eng Soon
 
PPTX
3 Steps Integrate Microsoft Graph with Azure Bot Services
Cheah Eng Soon
 
Microsoft Defender for Endpoint
Cheah Eng Soon
 
Azure Active Directory - Secure and Govern
Cheah Eng Soon
 
Microsoft Zero Trust
Cheah Eng Soon
 
MEM for OnPrem Environments
Cheah Eng Soon
 
Microsoft Threat Protection Automated Incident Response
Cheah Eng Soon
 
Azure Penetration Testing
Cheah Eng Soon
 
Azure Penetration Testing
Cheah Eng Soon
 
Microsoft Threat Protection Automated Incident Response Demo
Cheah Eng Soon
 
Microsoft Secure Score Demo
Cheah Eng Soon
 
Microsoft Cloud App Security Demo
Cheah Eng Soon
 
M365 Attack Simulation Demo
Cheah Eng Soon
 
Cloud Security Demo
Cheah Eng Soon
 
Azure Active Directory - External Identities Demo
Cheah Eng Soon
 
Azure WAF
Cheah Eng Soon
 
Azure Weekend 2020 Build Malaysia Bus Uncle Chatbot
Cheah Eng Soon
 
Microsoft Azure的20大常见安全漏洞与配置错误
Cheah Eng Soon
 
20 common security vulnerabilities and misconfiguration in Azure
Cheah Eng Soon
 
Integrate Microsoft Graph with Azure Bot Services
Cheah Eng Soon
 
Azure Sentinel with Office 365
Cheah Eng Soon
 
3 Steps Integrate Microsoft Graph with Azure Bot Services
Cheah Eng Soon
 

Recently uploaded (20)

PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
This slide provides an overview Technology
mineshkharadi333
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
Software Development Company | KodekX
KodekX
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 

SQLite with UWP

  • 1. Prepared by ENG SOON CHEAH Microsoft MVP
  • 2. Install SQLite-UAP extensions form NuGet Package Manager
  • 3. Next Install SQLite.Net-PCL extension from NuGet Package
  • 4. • Include 4 functions CRUD Operations • Bind data to a ListBox
  • 5. <Grid Background="#FFF589E2"> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="*"></RowDefinition> </Grid.RowDefinitions> <Button x:Name="CreateDBbutton" Grid.Row="0" Content="Create Local Database" HorizontalAlignment="Center" VerticalAlignment="Top" Click="button_Click" /> <Button x:Name="create" Grid.Row="1" Content="Create New Students" HorizontalAlignment="Center" Click="creat e_Click"></Button> <Button x:Name="read" Grid.Row="2" Content="Read Students List" Width="300" Click="read_Click" HorizontalAlig nment="Center"></Button> <Button x:Name="update" Grid.Row="3" Content="Update Details" Width="300" Click="update_Click" HorizontalAli gnment="Stretch"></Button> <ListView x:Name="allstudents" HorizontalAlignment="Stretch" Grid.Row="4"> <ListView.ItemTemplate> <DataTemplate> <TextBlock x:Name="ee" Text="{Binding Name}" FontSize="14"></TextBlock> </DataTemplate> </ListView.ItemTemplate> </ListView> </Grid>
  • 6. public class Students { [SQLite.Net.Attributes.PrimaryKey, SQLite.Net.Attributes.AutoIncrement] public int Id { get; set; } public string Name { get; set; } public string Address { get; set; } public string Mobile { get; set; } public Students() {} public Students(string name, string address, string mobile) { Name = name; Address = address; Mobile = mobile; } }
  • 7. public static void CreateDatabase() { var sqlpath = System.IO.Path.Combine(Windows.Stora ge.ApplicationData.Current.LocalFolder.Path, "Studentdb. sqlite"); using(SQLite.Net.SQLiteConnection conn = new SQLit e.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT. SQLitePlatformWinRT(), sqlpath)) { conn.CreateTable < Students > (); } }
  • 8. public void Insert(Students objContact) { var sqlpath = System.IO.Path.Combine(Windows.Storage.Appli cationData.Current.LocalFolder.Path, "Studentdb.sqlite"); using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.S QLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatform WinRT(), sqlpath)) { conn.RunInTransaction(() => { conn.Insert(objContact); }); } }
  • 9. // Retrieve the specific contact from the database. public Students ReadContact(int contactid) { var sqlpath = System.IO.Path.Combine(Windows.Storage.Appli cationData.Current.LocalFolder.Path, "Studentdb.sqlite"); using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.S QLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatform WinRT(), sqlpath)) { var existingconact = conn.Query < Students > ("select * fro m Students where Id =" + contactid).FirstOrDefault(); return existingconact; } }
  • 10. //Read All Student details public ObservableCollection < Students > ReadAllStudents() { var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Cur rent.LocalFolder.Path, "Studentdb.sqlite"); using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnectio n(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath)) { List < Students > myCollection = conn.Table < Students > ().ToList < Stud ents > (); ObservableCollection < Students > StudentsList = new ObservableCollecti on < Students > (myCollection); return StudentsList; } }
  • 11. //Update student detaisl public void UpdateDetails(string name) { var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Student db.sqlite"); using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.Win RT.SQLitePlatformWinRT(), sqlpath)) { var existingconact = conn.Query < Students > ("select * from Students where Name =" + name).FirstOrDe fault(); if (existingconact != null) { existingconact.Name = name; existingconact.Address = "NewAddress"; existingconact.Mobile = "962623233"; conn.RunInTransaction(() => { conn.Update(existingconact); }); } } }
  • 12. //Delete all student or delete student table public void DeleteAllContact() { var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Studentdb.sqlite"); using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformW inRT(), sqlpath)) { conn.DropTable < Students > (); conn.CreateTable < Students > (); conn.Dispose(); conn.Close(); } } Delete specific student //Delete specific student public void DeleteContact(int Id) { var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Studentdb.sqlite"); using(SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformW inRT(), sqlpath)) { var existingconact = conn.Query < Students > ("select * from Studentdb where Id =" + Id).FirstOrDefault(); if (existingconact != null) { conn.RunInTransaction(() => { conn.Delete(existingconact); }); } } }
  • 13. • Local Data Base SQLite for Windows 10 https://code.msdn.microsoft.com/Local- Data-Base-SQLite-for-5e6146aa