I. Installation
SQLite is a lightweight database and an acid-compliant associated database management system. I am using http://sqlite.phxsoftware.com/(an Open Source ADO. net provider for the SQLite database engine) directly, and the download is an EXE.
Then reference system. Data. SQLite. dllProgramSet;
If you still want to use LINQ in SQLite, you also need to reference the system. Data. SQLite. LINQ. dll assembly;
Ii. Create a database
After the installation is complete, open Visual Studio and create a data connection. You can see that the data source has an SQLite parameter.
Create a connection, as shown in. The SQLite database is saved as a file.
Iii. Database Maintenance
You can maintain SQLite data in Vs, for example:
You can use functions similar to SQL query analyzer in Vs, for example:
4. hybrid mode
After the installation is complete, you can directly reference the project set.
System. Data. SQLite
System. Data. SQLite. LINQ
Two assemblies, because the assemblies are loaded in runtime 4.0. Therefore, you must configure the following parameters in APP. config.
<? XML version = "1.0" encoding = "UTF-8" ?>
< Configuration >
< Startup Uselegacyv2runtimeactivationpolicy = "True" >
< Supportedruntime Version = "V4.0" />
</ Startup >
</ Configuration >
5. My testsCode Using System;
Using System. Collections. Generic;
Using System. componentmodel;
Using System. Data;
Using System. drawing;
Using System. LINQ;
Using System. text;
Using System. Windows. forms;
Using System. Data. SQLite;
NamespaceXg_demo
{
Public Partial ClassForm1: Form
{
PublicForm1 ()
{
Initializecomponent ();
}
Private Void Button#click ( Object Sender, eventargs E)
{
// Connection string reference
// String strcon = "datasource = test. db3; pooling = true; failifmissing = false ";
// "Northwindef (SQLite)" connectionstring = "provider = system. data. SQLite; Metadata = schemas \ northwindefmodel. CSDL | schemas \ northwindefmodel. MSL | schemas \ northwindefmodel. SQLite. SSDL; provider connection string = 'data source = dB \ northwindef. db '"
String Strcon = " Data Source = xg_database; pooling = true; Password = sa " ;
Sqliteconnection con = New Sqliteconnection (strcon );
Sqlitecommand cmd = New Sqlitecommand ( " Select * from student " , Con );
Sqlitedataadapter da = New Sqlitedataadapter (CMD );
Datatable dt = New Datatable ();
Da. Fill (DT );
Datagridview1.datasource = DT;
}
}
}
Learning Source: C # SQLite of local data storage solution
Download demo