如何创建一个新的SQLite数据库,所有表,对飞? [英] How can I create a new SQLite database, with all tables, on the fly?
问题描述
当用户启动我的应用程序,他或她可以创建一个新的项目,这意味着创建的所有表的新数据库。
When a user starts my app he or she can create a new project, which means creating a new database with all tables.
我不希望复制从旧的数据库/项目,因为在此期间中的表的结构,该表可能是由于由程序改变为更新。这将导致崩溃。
I don't want to copy the structure of the tables from an older database/project because in the meantime, the tables could have changed due to an update by the program. This would lead to crashes.
因此,与每一个应用程序的更新我部署,我也应该部署它创建数据库和表的脚本文件,对吧?
So with every application update I deploy, I should also deploy a script file which creates the database and tables, right?
我应该脚本文件的样子,你会怎么称呼它在C#
What should the script file look like and how would you call it in C#?
推荐答案
也许这将帮助?
SQLiteConnection.CreateFile("c:\\Ik.db");
即时创建一个新的数据库并在其上执行查询。查询应该是这样的:
Create a new database on the fly and execute a query on it. The query should be something like this:
CREATE TABLE IF NOT EXISTS [Setting](
[ID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[Key] NVARCHAR(2048) NULL,
[Value] NVARCHAR(2048) NULL
);
这篇关于如何创建一个新的SQLite数据库,所有表,对飞?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!