news 2026/9/24 14:13:23

SQLite NET

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
SQLite NET

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)
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!