110,571
社区成员
发帖
与我相关
我的任务
分享
//
public static void CreateDb()
{
string dbPath = @"e:\DataBase\Demo.db3";
if (!File.Exists(dbPath))
{
File.Create(dbPath);
}
SQLiteHelper.CreatTable(dbPath);
}
// Create Table
public static void CreatTable(string dbFile)
{
using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + dbFile))
{
connection.Open();
using (SQLiteCommand command = new SQLiteCommand(connection))
{
command.CommandText = "Create Table Demo(id integer not null primary key autoincrement unique)";
command.ExecuteNonQuery();
}
}
System.Data.SQLite.SQLiteConnection.CreateFile(filePath)
//其中filePath是物理路径+文件名,并且所在文件夹必须存在。