If you just want C # to reference the DLL development program and don't want to create a database, you can start from the third part.
The first step is to create a SQLite database
1) CLP in Shell mode
Download CLP first
Official site http://www.sqlite.org/
Click Download to enter the download page http://www.sqlite.org/download.html
Roll over to find Precompiled Binaries for Windows on the page
There is one called sqlite-shell-win32-x86-3080403.zip, in which the later version number will be constantly changing. The main way to distinguish it is a shell in the name
Unzip this ZIP and you will see the sqlite3.exe file included in it.
1. Copy sqlite3.exe to the C: \ Windows \ temp directory (in fact, you can copy it at will)
2. Run cmd
3. In cmd, use the command cd .. to return to the root directory of drive C, then cd windows, cd temp, enter two lines of command, move the directory to the directory where the sqlite3.exe file is stored (in fact, cmd should be able to complete a command , But I do n’t understand the cmd command, and it will do just fine)
4. Enter sqlite3.exe in the cmd form to open the clp in shell mode. If no error is reported, the cmd window prompts information such as the version number.
5. Entering the .help command prompts many command prompts.
6. Enter .exit to exit SLP in shell mode
(The three steps 4, 5, and 6 are just demonstrations and have no practical effect. Step 7 below starts to use the command to create the library.)
7. Enter in the cmd window
sqlite3 test.db
(Note that this step is different from the fourth step. You must give the database name here. If you want to start as the fourth step, the database is stored in memory, and the cmd data is gone.)
8. Create the database
sqlite> create table test (id integer primary key, value text);
(After performing this step, a .db file will be created. The test.db file was not created when the seventh step was performed. This is due to the delayed creation of sqlite's internal principles. It should be related to the character set and format. It does matter, but in any case, the seventh step must make the database name)
9. Insert data
sqlite> insert into test (id, value) values (1, 'eenie');
sqlite> insert into test (id, value) values (2, 'meenie');
sqlite> insert into test (value) values ('miny');
sqlite> insert into test (value) values ('mo');
10. Find the data
sqlite> select * from test;
You can also layout the format
sqlite> .mode column
sqlite> .headers on
sqlite> select * from test;
This makes it clearer. Pay attention to which codes are semicolons and which are optional.
----------------------
Get database schema information
sqlite> .tables
sqlite> .schema test
sqlite> .schema
Step 2.Manage SQLite with visual management tools
Using cmd mode is too painful, it will be much easier to change to a visual management tool.
I use sqliteexpert. The tool has two versions: Personal Edition and Professional Edition. The personal edition is enough for me.
Official Website: http://www.sqliteexpert.com/
It ’s all English again. If you do n’t understand English, you can use a web page translation tool. After translation, it ’s easy to find what we want.
Click Download to enter the download page http://www.sqliteexpert.com/download.html
The one above is the professional version, which clearly states License: 30 days trial, and the one below is the personal version, which clearly states License: Freeware (free ^^)
Click the Dlwoload button of the personal version, a download box will pop up, save and install it.
It is best to check the Create a desktop icon button during installation. There is no such startup method on the desktop. You have to find it in the "Start" menu. Of course, it doesn't matter.
It can be used after installation.
(Databases created with tools do not have a suffix. If you want to become the first step, let the database have a .db suffix, you can add it manually, but do n’t forget the corresponding link string in the program. )
The third step is to get the SQLite DLL
(This is the point. Obviously, developing a database can be created by someone else, but programmers can't avoid this step if they want to develop.
This article was written on May 19, 2014, because the website may change in the future. For example, the name of the download file corresponding to the tutorial I am looking for is no longer correct, so there is no way to find the DLL I want to download based on the name they provided. )
Official site http://www.sqlite.org/
Click Download to enter the download page http://www.sqlite.org/download.html
This page has a version of sqlite used in different systems. If you do not understand English, you can use a web page translation tool. After translation, it will be easy to understand.
If you want to develop on windows system with .net C #, you should download Precompiled Binaries for .NET (pre-compiled binary file is .net)
(Don't download sqlite-dll-win32-x86-3080403.zip for Precompiled Binaries for Windows,
The DLL inside it will report an error: Failed to add a reference to "..... sqlite3.dll", please ensure that this file is accessible and is a valid assembly or COM component. )
After entering the Precompiled Binaries for .NET page, there will be a lot of downloads. Take a closer look. In fact, there are 3 main categories.
1.Setups for
2.Precompiled Binaries (precompiled binaries)
3.Precompiled Statically-Linked
Each category corresponds to 32-bit and 64-bit systems, and different .NET Framework versions. In addition to these 3 categories, there are some source code, such as Win CE
What we want is to download the target platform (X86 or 64bit) corresponding to the program you developed from 2.Precompiled Binaries, and the .net version of the program you developed.
I downloaded the 32-bit version of the .NET Framework 4.0.
Decompressing this compressed package, I will find there are a lot of things, and I ca n’t figure out what is the use. Anyway, I can find a dll file System.Data.SQLite.dll from inside,
By referencing this file to our .net program, you can operate the SQLite database with the suffix .db.
(I do n’t know why, in fact, the dlls in 2.Precompiled Binaries and 3.Precompiled Statically-Linked can be used, I do n’t know what is the difference between static and non-static)
The fourth step is to create a C # project, then right-click and add the third downloaded DLL. Remember to put the DLL in the bin / debug directory first.
You can put both the dll and the created database in the debug or release directory, so you don't need to set the path to create a new DLL and database, but use a relative path. After the program is developed, you can directly package Debug or Release.
It was developed after that. SQLite syntax has many functions that are not supported. For example, it supports LEFT OUT JOIN, RIGHT OUT JOIN and FULL OUT JOIN note. Anyway, the development tool query is wrong.
-
Reprinted at: https://www.cnblogs.com/springyeah/p/3736661.html