slitetest/Form1.cs

(开头部分) 11KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SQLite;

namespace slitetest
{
    public partial class Form1 : Form
    {
        //数据库连接
        SQLiteConnection m_dbConnection;
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {

        }


        #region 三、创建数据库

        //SQLite 是文件型的数据库,创建很简单,直接指定一个数据库文件名,后缀名不一定非得是“.sqlite”,后缀随便命名为".db"也成。运行 SQLiteConnection.open 就会创建个空的指定名字的数据库文件。
        //由于它是文件型的,我们也可以直接用 System.IO.File.Create() 来创建一个空的文件。
        static void CreateDB()
        {
            string path = Application.StartupPath + "\\test.db";
            SQLiteConnection cn = new SQLiteConnection("data source=" + path);
            cn.Open();
            cn.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            CreateDB();
        }
        #endregion

        #region 四、删除数据库
        /// sqlite 命令中好像没有提供删除整个数据库的命令,但是由于它是个文件型的,我们直接用 System.IO.File.Delete(string path) 方法来删除文件。
        static void DeleteDB()
        {
            string path = Application.StartupPath + "\\test.db";
            if (System.IO.File.Exists(path))
            {
                System.IO.File.Delete(path);
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            DeleteDB();
        }
        #endregion

后面还有 276 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。