如何使用Sqlite-Net创建db3数据库 [英] How to create a db3 database with Sqlite-Net
问题描述
在一个Mono项目中,我想创建一个数据库并使用它,而Sqlite-Net则对Mono进行了优化,因此可以做到这一点.但是我找不到任何有关如何使用它创建数据库的文档.所以我只是尝试连接到它,希望它会说数据库不存在,我将创建一个数据库",但是我遇到了一个例外,因此处理不起作用
readonly string _pathToDatabase = "Meter_db.db3";
public InstallMeterRepository()
{
if(!File.Exists(_pathToDatabase))
{
using (var conn = new SQLite.SQLiteConnection(_pathToDatabase))
{
conn.CreateTable<InstalledMeter>();
}
}
}
如果要创建新数据库,则需要驱动程序: http://system.data.sqlite.org/index .html/doc/trunk/www/downloads.wiki
您也可以在这里检查: http://sqlite.phxsoftware.com/
有了这个FREEWARE管理器,您就可以对数据库进行任何操作:(推荐!) SQLite2009 Pro企业管理器 http://osenxpsuite.net/?xp=3&uid=managementtools >
开心发展!
恐惧
In a mono project I want to create a database and use that, and Sqlite-Net is optimzied for mono so would go with that. But I cant find any documentation how to create a database with it. So I just try to connect to it and hope it will say "Database dont exists, I will create one" but I get an exception so that approch dont work
readonly string _pathToDatabase = "Meter_db.db3";
public InstallMeterRepository()
{
if(!File.Exists(_pathToDatabase))
{
using (var conn = new SQLite.SQLiteConnection(_pathToDatabase))
{
conn.CreateTable<InstalledMeter>();
}
}
}
If you want to create a new database, you need the driver: http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
You can check here too: http:// sqlite.phxsoftware.com/
And with this FREEWARE manager, you can do whatever you want with your database: (Recomended!) SQLite2009 Pro Enterprise Manager http://osenxpsuite.net/?xp=3&uid=managementtools
Happy develop!
Fear
这篇关于如何使用Sqlite-Net创建db3数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!