文件名称:Sqlite 操作类 C# .net
文件大小:389KB
文件格式:RAR
更新时间:2016-01-30 11:35:06
sqlite dll
Sqlite 操作类 C# .net,嵌入式SQL //创建一个数据库文件 string datasource = @"d:/ChinaPower.s3db"; // System.Data.SQLite.SQLiteConnection.CreateFile(datasource); //连接数据库 System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(); System.Data.SQLite.SQLiteConnectionStringBuilder connstr = new System.Data.SQLite.SQLiteConnectionStringBuilder(); connstr.DataSource = datasource; conn.ConnectionString = connstr.ToString(); conn.Open(); //创建表 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(); //插入数据 // sql = "INSERT INTO test VALUES('ekinglong','mypassword')"; // cmd.CommandText = sql; //cmd.ExecuteNonQuery(); //取出数据 string sql = "SELECT * FROM score"; cmd.CommandText = sql; System.Data.SQLite.SQLiteDataReader reader = cmd.ExecuteReader(); StringBuilder sb = new StringBuilder(); while (reader.Read()) { sb.Append("username:").Append(reader.GetInt32(0)).Append("\n") .Append("password:").Append(reader.GetString(1)); } Console.WriteLine(sb); Console.Read();
【文件预览】:
SQLiteHelper.cs
System.Data.SQLite.DLL