You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.8 KiB
62 lines
1.8 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Data;
|
|
using System.IO;
|
|
using Microsoft.Data.Sqlite;
|
|
using System.Data.Common;
|
|
using System.Windows.Media.Animation;
|
|
using System.Data.SQLite;
|
|
|
|
namespace DyeingComputer.UserClass
|
|
{
|
|
internal class SqliteHelper
|
|
{
|
|
|
|
/// <summary>
|
|
/// 事务的基类
|
|
/// </summary>
|
|
private DbTransaction DBtrans;
|
|
|
|
/// <summary>
|
|
/// 数据库地址
|
|
/// </summary>
|
|
private readonly string dbFile = "Data Source=" + Environment.CurrentDirectory + "\\DataBase\\COMPUTER.db;Version3";
|
|
/// <summary>
|
|
/// 数据库密码
|
|
/// </summary>
|
|
private readonly string mPassWord;
|
|
private readonly string LockName = null;
|
|
/// <summary>
|
|
/// 打开一个SQLite数据库文件,如果文件不存在,则创建(无密码)
|
|
/// </summary>
|
|
/// <param name="dataFile"></param>
|
|
/// <returns>SQLiteConnection 类</returns>
|
|
private SQLiteConnection OpenConnection(string dataFile)
|
|
{
|
|
if (dataFile == null)
|
|
{
|
|
throw new ArgumentNullException("dataFiledataFile=null");
|
|
}
|
|
if (!File.Exists(dataFile))
|
|
{
|
|
SQLiteConnection.CreateFile(dataFile);
|
|
}
|
|
SQLiteConnection conn = new SQLiteConnection();
|
|
SQLiteConnectionStringBuilder conStr = new SQLiteConnectionStringBuilder
|
|
{
|
|
DataSource = dataFile
|
|
};
|
|
conn.ConnectionString = conStr.ToString();
|
|
conn.Open();
|
|
return conn;
|
|
}
|
|
|
|
public void qe()
|
|
{ }
|
|
public void SqliteHe()
|
|
{ OpenConnection(dbFile); }
|
|
}
|
|
}
|
|
|