当我试图访问一个附加的数据库文件时,出现了一个“没有这样的表”错误,该文件位于一个有效的SQLiteConnection上,并且带有已构建的模式。
在“main”连接上保存了一些测试数据之后,我附加了该文件,然后尝试将数据从“main”导出到该文件以供以后使用。以下是用于附加文件的代码:
private static void _attachDatabase(SQLiteConnection conn, string dataFile) {
var cmd = new SQLiteCommand(conn)
{
CommandText = string.Format("ATTACH '{0}' AS {1}", dataFile, ATTACHED_DB)
};
_log.Debug(cmd.CommandText);
cmd.ExecuteNonQuery();
}
命令的日志输出是
"...\bin\Debug\testData.db3' AS asdf" where testData.db3 is the file.
但是,当我试图插入到文件中时,我在这篇文章的末尾得到了错误信息。
有没有从提供的信息中看到问题?另外,我是否应该能够在调试器中的某个地方看到附加的db(“asdf”)?
干杯,
柏瑞尔
测试“SQLiteTesting.Helpers.QueryTests.Director_if_Tim_Burton_query_should_return_one_movie”失败:TestFixtureSetUp在QueryTests中失败
TestFixture失败:System.Data.SQLite.SQLite异常:SQLite错误
没有这样的表:asdf.ActorRole
在System.Data.SQLite.SQLite3.Prepare(SQLiteConnection cnn,String strSql,SQLiteStatement previous,UInt32超时,String&stremain)
位于System.Data.SQLite.SQLiteCommand.BuildNextCommand()
在System.Data.SQLite.SQLiteCommand.GetStatement(Int32索引)
位于System.Data.SQLite.SQLiteDataReader.NextResult()
在System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand命令,命令行为)
在System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior行为)
在System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()上
在SQLiteTesting.Helpers.SQLiteLoader.\u copyTableData(SQLiteConnection conn,String source,String destination)中,位于C:\Users\Lord&Master\Documents\Projects\Data\NHib Projects\Cookbook\SQLiteTesting\Helpers\SQLiteLoader.cs:第68行
在SQLiteTesting.Helpers.SQLiteLoader.ExportData(SQLiteConnection conn,String dataFile)中,位于C:\Users\Lord&Master\Documents\Projects\Data\NHib Projects\Cookbook\SQLiteTesting\Helpers\SQLiteLoader.cs:line 30
在C:\Users\Lord&Master\Documents\Projects\Data\NHib Projects\Cookbook\SQLiteTesting\Helpers\QueryTests.cs中的SQLiteTesting.Helpers.QueryTests.onfixtresetup()第25行
在C:\Users\Lord&Master\Documents\Projects\Data\NHib Projects\Cookbook\SQLiteTesting\Helpers\BaseFixture.cs中的SQLiteTesting.Helpers.BaseFixture.FixtureSetUp()第23行
2010-11-23 18:15:36835调试附加“…\bin\DEBUG\testData.db3”作为asd
2010-11-23 18:18:12935调试插入到asdf.ActorRole SELECT*FROM ActorRole