Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to work with SQLite in WPF

Tags:

c#

sqlite

wpf

I have WPF APP I want to use SQLite How to do such thing?

(BTW I understand how to do such thing in Adobe Air but in WPF it's a big question for me so some explanation made on\with comparing how to's is Big +...)

like image 903
Rella Avatar asked Dec 19 '09 05:12

Rella


People also ask

Can I use SQLite with C#?

Getting Started with SQLite from a . Open Visual Studio, select new project, and, in Visual C#, select “Console Application” and provide the name as SQLiteDemo. Click OK. To connect SQLite with C#, we need drivers. Install all required SQLite resources from the NuGet package, as pictured in Figure 1.

Can I use SQLite without installing?

SQLite does not need to be "installed" before it is used. There is no "setup" procedure. There is no server process that needs to be started, stopped, or configured. There is no need for an administrator to create a new database instance or assign access permissions to users.

Can I use SQLite in web application?

SQLite is a database engine that is distributed with Python and supports most of the SQL standard. It is ideal for developing database backed applications and because it uses the same SQL as larger systems, it is generally easy to port applications to a production database like MySQL or Oracle for deployment.

Can I use SQLite in Pycharm?

Databases can work locally, on a server, or in the cloud. The plugin supports MySQL, PostgreSQL, Microsoft SQL Server, SQLite, MariaDB, Oracle, Apache Cassandra, and others.


1 Answers

You can use SQLite in WPF the same way you would use SQL Server, Oracle or any other database -- via ADO.NET or (better) via an object-relational mapper. An ORM is probably a better option because a good ORM will handle things like property change notifications (critical for data binding) for you.

The basic technique you are looking for is to define a model which you will load and save via the ORM, and databind your UI to using data binding. (The full version of this pattern is called model-view-viewmodel or MVVM but as a beginner you probably want to focus on the basics of creating and binding to a domain model first and tackle the more complex aspects of MVVM later.)

For the SQLite / ADO.NET side of things, see System.Data.Sqlite, as covered in answers to your earlier question.

For object-relational mapping, see numerous Stack Overflow questions, especially https://stackoverflow.com/questions/249550/what-orm-frameworks-for-net-do-you-like-best and Lightweight alternatives to NHibernate.

like image 132
itowlson Avatar answered Sep 26 '22 07:09

itowlson