SQLite, as long as you have used a database, you should not be afraid of it. It is enough to think of it as a simple database, but it only supports limited data. Next, let me talk about how to use it. My environment is vs2008 + QT.
Like most people, I first need to Google the Code. The Code is as follows:
# Include <qtgui/qapplication> <br/> // # include <qapplication> <br/> # include <qsqldatabase> <br/> # include <qtsql> <br/> # include <qsqlitedriver> <br/> int main (INT argc, char * argv []) <br/>{< br/> qapplication app (argc, argv); </P> <p> qsqldatabase DB = qsqldatabase :: adddatabase ("qsqlite"); <br/> dB. setdatabasename ("test. DB "); <br/> // test. DB is a database file created through the SQLite Program, under the current folder <br/> If (! DB. open () <br/>{< br/> return 0; <br/>}< br/> return app.exe C (); <br/>}< br/>
Run the command to view the result:
Qsqldatabase: qsqlite driver not loaded
Qsqldatabase: available drivers:
At this step, we are depressed .....
The solution is as follows:
Step 1: Add qsqlite. lib to the link of the project.
The method is: select your project> Properties> Configuration Properties> linker> input> additional dependency> Add qsqlite. Lib.
Step 2: Modify the adddatabase method.
To:
Qsqldatabase DB = qsqldatabase: adddatabase (New qsqlitedriver (), "qsqlite ");
Re-compile, O, hey. Of course, you can also add q_import_plugin (qsqlite) directly above the main function without modifying the content here)
OK. This is the end !!!!
I planned to end it here, but some of my siblings won't be SQLite. So I re-wrote how to use sqlite3
First, download a sqlite3.exe file. Go to csdn and search for it.
Second, use the authorization command to go to your sqlite3.exe directory.
Step 3: Type sqlite3.exe test. DB
The fourth step is to enter the; this semicolon will show that you have the file test. DB in your current project. This is the database file we want.
Of course, you can also directly create a table create table (age int Nam varchar (10 ));
O, this is the whole process of table creation !!!!