The SQLite database structure is as follows: Create TABLE admin (username text, age integer );
The following uses C # to demonstrate how to add, query, modify, and delete records in the SQLite database:
Using System;
Using System. Data;
Using System. Configuration;
Using System. Collections;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Web. UI. HtmlControls;
Using System. Data. SQLite; // reference System. Data. SQLite
Public partial class Sqlite: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
String _ connectionString = @ "Data Source = F: \ mzwucom \ bbs \ db1.db ";
String _ SQL;
SQLiteConnection conn = new SQLiteConnection ();
SQLiteCommand cmd;
SQLiteDataReader dr;
Conn. ConnectionString = _ connectionString;
Conn. Open ();
_ SQL = "insert into admin (username, age) values ('user" + (new Random (). Next (1,100) + "', 22 )";
Cmd = new SQLiteCommand (_ SQL, conn );
Cmd. ExecuteNonQuery ();
_ SQL = "select * from admin ";
Cmd = new SQLiteCommand (_ SQL, conn );
Dr = cmd. ExecuteReader ();
While (dr. Read ())
{
Response. Write (dr ["username"]. ToString () + "," + dr ["age"]. ToString () + "<br/> ");
}
}
}