参考文章参考
class db
{
private SQLiteConnection dbConnection;
//private SQLiteCommand cd;
//private SQLiteDataReader read;
public SQLiteConnection lian(string path)
{
//创建连接字符串
try
{
string databaseFileName = path;
string connectionString = "data source = " + databaseFileName;
//链接数据库
dbConnection = new SQLiteConnection(connectionString);
dbConnection.Open();
}
catch (Exception e)
{
Console.Write(e + "对象");
}
return dbConnection;
}
}
db b= new db();
//创建连接字符串
string path="C:/QQ.db";
string count;
string sqlc = "select count(*) as num from '" + str + "';";
//加载sql
SQLiteCommand cdsc = new SQLiteCommand(sqlc, b.lian(path));
//执行
SQLiteDataReader drc = cdsc.ExecuteReader();
if (drc.Read()) {
count = drc["num"].ToString();
Console.Write(count);
}



