Welcome to Xamarin Forms Tutorials in Hindi In this video you will learn how to use SQLite in xamarin forms and how to create database and insert data.
When I Click show data it shows nothing. What went Wrong ? Code as below ?xml version="1.0" encoding="utf-8" ?>
using SQLite; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using Xamarin.Forms; using video33.Model; namespace video33 { // Learn more about making custom code visible in the Xamarin.Forms previewer // by visiting aka.ms/xamarinforms-previewer [DesignTimeVisible(false)] public partial class MainPage : ContentPage { readonly private SQLiteConnection conn; public video33.Model.Student student; public MainPage() { InitializeComponent(); conn = DependencyService.Get().GetConnection(); conn.CreateTable(); } private void SaveButton_Clicked(object sender, EventArgs e) { Student student = new Student(); student.Name = Name.Text; student.Address = Address.Text; conn.Insert(student); Name.Text = ""; Address.Text = ""; } private void ShowButton_Clicked(object sender, EventArgs e) { var data = (from stu in conn.Table() select stu); DataList.ItemsSource = data; } } }
Sir I have got exception :Index was outside the bounds of the array(indexoutofrangeException) And one more error : NInterpret.InterpretedObject' cannot be converted to type 'System.Collections.IEnumerable'. (ArgumentException)] Plz help me sir to handle these exceptions
You dont need to copy DB,as here I am creating SQLite_Android class inside android project,same create this class to your iOS,Windows project Database will automatically generate with platform basis.
I made a login page for my project it's a music app ,i watched your video and get same error at var conn=new sqliteconnection(path) Pls help me out i also change dbpath and dbname as you told pls help me out it shows error as system.typeloadexception.'VTable setup of type sqlitepcl.sqlite3provider_e_sqlite3 failed'
Database file stored on that path which we declared while creation of connection. It will be a internal folder that you cant access, below android version 6 you can see but after that you cant.
sir i m beginner ,how to show 3 records like name,address,email?how to show 3rd field like email.u show only 2 i.e name and address.what are the changes in MainPage.xaml?
Dear,To show multiple data,use viewcell not textcell..If you are absolute beginners then you can join my online training.for more details contact +918444835044
SPTutorials..... मैंने एक वीडियो देखी ।। उस वीडियो मे उसने बटन,या, लेबल, etc , उसने बटन का कंट्रोल find किया।। लेकिन आप ने save बटन लिया तो उसका कंट्रोल find नही किया।।।। Txtsave = findViewById(save)(resources.Id.save)
Dear @myexpert_education, in this video i have two button save & show,save button create the database connection and insert the data,and show button is for fetch the all data from database and store to a list and shown on ListView.This is very basic of SQLite.Next video you will learn more details about SQLite.If you have any doubt then comment here.
Physical location of database file. Superb tutorial no doubt
very good but it's pretty short. I hope idol give out more videos on sqlite.
When I Click show data it shows nothing. What went Wrong ? Code as below
?xml version="1.0" encoding="utf-8" ?>
using SQLite;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using video33.Model;
namespace video33
{
// Learn more about making custom code visible in the Xamarin.Forms previewer
// by visiting aka.ms/xamarinforms-previewer
[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{
readonly private SQLiteConnection conn;
public video33.Model.Student student;
public MainPage()
{
InitializeComponent();
conn = DependencyService.Get().GetConnection();
conn.CreateTable();
}
private void SaveButton_Clicked(object sender, EventArgs e)
{
Student student = new Student();
student.Name = Name.Text;
student.Address = Address.Text;
conn.Insert(student);
Name.Text = "";
Address.Text = "";
}
private void ShowButton_Clicked(object sender, EventArgs e)
{
var data = (from stu in conn.Table() select stu);
DataList.ItemsSource = data;
}
}
}
How to encrypt sqlite db in xamarin forms....any idea....
Nice
thank you so much this helps me thank U thank U
Sir I have got exception :Index was outside the bounds of the array(indexoutofrangeException)
And one more error : NInterpret.InterpretedObject' cannot be converted to type 'System.Collections.IEnumerable'. (ArgumentException)]
Plz help me sir to handle these exceptions
Vikash Kumar put that code under try catch block and debug this code,note that from which line you are getting this exception.
Hi how to copy our existing SQLite DB in All Plate form.
You dont need to copy DB,as here I am creating SQLite_Android class inside android project,same create this class to your iOS,Windows project
Database will automatically generate with platform basis.
But in my case my db already exist with table and Data. So how I am use that dB
@@sonuaec From where you get your DB file? if you already have your database then use it,simply executing sql query.
i hope ,you will create complete project soon
@Rohit, after completing Xamarin forms advance topics i will definitely create an App.so keep patient :)
where to save sqlite.db file in mobile .
It saves under mobile package directory
जब Show Data button पे Click करता हु तो कूछ भी नही दिखता है
But I m confused....
DependencyService.Get().GetConnection() return null object reference and application get crashed
Add assembly info inside your sqlite android class
@@SPTutorials already done that sir in android as well as in ios but still issue occur
debug it properly,so that you will get actual error
when i run using vs 2022 it will run fine..Other wise crash the application.whats the reason
Check logs.
thankyou * 200
I made a login page for my project it's a music app ,i watched your video and get same error at var conn=new sqliteconnection(path)
Pls help me out i also change dbpath and dbname as you told pls help me out it shows error as system.typeloadexception.'VTable setup of type sqlitepcl.sqlite3provider_e_sqlite3 failed'
Pls help me out i have to submit the project
Use sqlite-pcl-net library and follow same steps.
@@SPTutorials pls can you elaborate a little i mean where to use it ? I have install nuget packages.i mean how to use sqlite-pcl-net library?
Follow this article www.c-sharpcorner.com/article/working-with-sqlite-in-xamarine-forms-application/
but where is database file
Database file stored on that path which we declared while creation of connection. It will be a internal folder that you cant access, below android version 6 you can see but after that you cant.
It was great. Can you tell me that how can i coonect already created sqlite with xamarin forms?
using db name and db path
How to save this json :
{
"status": "success",
"data": {
"name": "Ashish",
"salary": "1",
"age": null,
"id": 85
}
}
Thank you very much to upload this video
very good . Please tell me How to use joins with multiple tables to Get Data like Sql server in sqlite.
Hello,you can use your sql server queries as sqlite.the basic queries are universal so you can use joins same as sql server joins.
Thanks Sir.
How you have used this using android. assemblies in your project I am unable to find in my project
Dear, can you tell me more details? are you asking for assembly references while writing platform specific codes?
can you share code, please?
When working with SQlite Visual Studio, work stops for what?
see exeption message and find out the problem.
sir as a beginner kiya me sqlite ko baadme seekh sakta hu? yaa ye abhi seekhna jroori he ? please please reply
Learn it when you need it.
@@SPTutorials Ok Thanks
thanks mem...
next try with sqlite-net sqlcipher
How yo protect or encrypt sqlite db in xamarin forms.....plz help
sir i m beginner ,how to show 3 records like name,address,email?how to show 3rd field like email.u show only 2 i.e name and address.what are the changes in MainPage.xaml?
Fetch the columns that you need,and make sure that the base class should have that property then you can simply use this.
@@SPTutorials yes i did .fetch the column and add property
you show only name and address if i add email what are the changes in in textcell tag
Dear,To show multiple data,use viewcell not textcell..If you are absolute beginners then you can join my online training.for more details contact +918444835044
@@SPTutorials ok.thanku sir
That ,,,, when does control find but you don't control find
Dear, @myexpert_education I can't get it? can you explain briefly?
SPTutorials..... मैंने एक वीडियो देखी ।। उस वीडियो मे उसने बटन,या, लेबल, etc , उसने बटन का कंट्रोल find किया।। लेकिन आप ने save बटन लिया तो उसका कंट्रोल find नही किया।।।।
Txtsave = findViewById(save)(resources.Id.save)
koi Institute hai jo xamarin sikhata jo...
Dear @myexpert_education, in this video i have two button save & show,save button create the database connection and insert the data,and show button is for fetch the all data from database and store to a list and shown on ListView.This is very basic of SQLite.Next video you will learn more details about SQLite.If you have any doubt then comment here.