【问题标题】:SQLite error no such table, when using it with DBLinq in C#SQLite 错误没有这样的表,在 C# 中与 DBLinq 一起使用时
【发布时间】:2017-03-21 17:43:52
【问题描述】:

我使用 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 执行命令创建一个新表,它将抛出“表已存在错误”。

谁能帮我解决这个问题。

如果您需要更多代码或调试跟踪,请询问,我会发布它们。

【问题讨论】:

    标签: c# sqlite dblinq


    【解决方案1】:

    解决了这个问题。问题出在由 DBMetal 创建的映射类(DBML 文件)中,它的表名与 SQLite 无法识别的完整命名空间一样。它现在就像一个魅力。 ——

    【讨论】:

      猜你喜欢
      • 2015-05-11
      • 2010-12-29
      • 1970-01-01
      • 2016-11-18
      • 1970-01-01
      • 2020-05-24
      • 2019-12-06
      • 1970-01-01
      • 2021-10-20
      相关资源
      最近更新 更多