SQLite ADO. Net:
Http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
1. Use Add references to reference system. Data. SQLite. dll in the bin directory of the SQLite ADO. net installation directory.
2. Create a database file: because it is always a 0-byte file, I/O can also be used (?!).
System. Data. SQLite. sqliteconnection. createfile (datasource );
3. Connect to the database
System. Data. SQLite. sqliteconnection conn = new system. Data. SQLite. sqliteconnection (connectionstring );
Connectionstring contains some database configuration information, such as database files and password opened by the database. You can use system. Data. SQLite. sqliteconnectionstringbuilder to create connectionstring.
4. Creating tables and reading data are not much different from access or ms SQL.
// Create a database file string datasource = "H:/test. DB "; system. data. SQLite. sqliteconnection. createfile (datasource); // connect to the database system. data. SQLite. sqliteconnection conn = new system. data. SQLite. sqliteconnection (); system. data. SQLite. sqliteconnectionstringbuilder connstr = new system. data. SQLite. sqliteconnectionstringbuilder (); connstr. datasource = datasource; connstr. password = "admin"; // set the password, SQLite ADO. net implements Database Password protection Conn. connectionstring = connstr. tostring (); Conn. open (); // create a table system. data. SQLite. sqlitecommand cmd = new system. data. SQLite. sqlitecommand (); string SQL = "CREATE TABLE test (username varchar (20), password varchar (20)"; cmd. commandtext = SQL; cmd. connection = conn; cmd. executenonquery (); // insert data SQL = "insert into test values ('dotnetthink', 'mypassword')"; cmd. commandtext = SQL; cmd. executenonquery (); // fetch data SQL = "select * from test"; cmd. commandtext = SQL; system. data. SQLite. sqlitedatareader reader = cmd. executereader (); stringbuilder sb = new stringbuilder (); While (reader. read ())... {sb. append ("username :"). append (reader. getstring (0 )). append ("\ n "). append ("Password :"). append (reader. getstring (1);} MessageBox. show (sb. tostring ());