我使用SQLite管理员创建了一个数据库。它包含3个表,数据库位于文档文件夹中。我还使用DBMetal为Linq创建了映射类。
下面的应用程序是数据库连接的代码,并将新数据插入SongMasterLocal。
static SQLiteConnection con = new SQLiteConnection(@"data source=C:\\Users\\Kam\\SongDb.s3db");
SongDBML.SongDBMLDataContext dCon=null;
try
{
dCon = new SongDBML.SongDBMLDataContext(con);
SongDBML.SongMasterLocal tempSongMaster = new SongDBML.SongMasterLocal();
tempSongMaster.SongFilePath = this.FilePath;
tempSongMaster.Cleaned = true;
dCon.Connection.Open();
dCon.Connection.BeginTransaction();
dCon.GetTable<SongMasterLocal>().InsertOnSubmit(tempSongMaster);
//dCon.SongMasterLocal.InsertOnSubmit(tempSongMaster);
dCon.GetTable<NewTags>().InsertOnSubmit(tempNewTags);
dCon.SubmitChanges();
return true;
}
catch (Exception e)
{
dCon.Connection.Close();
//throw e;
}
当我执行代码时,我得到SQLite错误:没有这样的表存在SongMasterLocal
如果我尝试使用SQLite执行命令创建一个新表,它将抛出“表已存在错误。”
任何人都可以帮我解决问题。
如果您需要更多代码或调试跟踪,请询问,我会发布它们。
答案 0 :(得分:0)
修正了问题。问题出在DBMetal创建的映射类(DBML文件)中,它具有表名和完整命名空间,而SQLite无法识别它。它现在就像魅力一样。 -