SQLite NET
2026/5/25 14:16:57 网站建设 项目流程

C# 程序中使用 SQLite 数据库

using System; using System.Data; using System.Data.SQLite; //C# 使用 SQLite 数据测试程序 public class Program { public static void Main(string[] args) { using (SQLiteConnection con = new SQLiteConnection("Data Source=c:\\test.db3;Pooling=true;FailIfMissing=false")) { //打开数据库文件 c:\\test.db3,不存在则创建 con.Open(); using (SQLiteCommand cmd = new SQLiteCommand()) { cmd.Connection = con; //检查是否存在表 test,不存在则创建 Boolean testTableExists = false; cmd.CommandText = "SELECT * FROM sqlite_master WHERE type='table' and name='test'"; using(SQLiteDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { testTableExists = true; } } if (!testTableExists)

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询