System.Data.SQLite“No such Table”执行Query时发生错误 [英] System.Data.SQLite "No such Table" error occures when executing Query
问题描述
我有一个SQLite数据库设计使用SQLite数据库浏览器2.0 b1我已经使用System.Data.SQLite。
I have a SQLite DB designed using "SQLite Database Browser 2.0 b1" I have used the System.Data.SQLite.
我使用的是Visual Studio 2010,并已在资源中添加我的数据库,这是我的连接字符串
I am using Visual Studio 2010, and have added my DB in the Resources and this is my connection string
sql_con = new SQLiteConnection(Data Source =+ CryptoFile.Properties.Resources.Database1 +。db; Version = 3; New = False; Compress = True;);
它预制
mySQLconnection.Open();
没有问题,它打开数据库...
然而..当我尝试处理/执行查询以下行:
with no problems it opens the Database... However .. when I try to process/Execute a Query the following line:
SQLiteDataReader reader = sql_cmd.ExecuteReader();
SQLite错误
.. Tablename
没有这样的表:
SQLite error
no such table:
..Tablename
因为连接被用于连接部分是在1函数中以其他形式返回值到SQLite Connection,所以不要打扰这里的命名,我使用了Finisar.SQLite ...
和所有的代码已经工作之前...但因为我无法发布项目与数据库我已经使用系统.Data.SQLite
cause the connection is used over and over the connection part is in 1 function returns the value to SQLite Connection in other forms, so don't bother with the namings here I have used the Finisar.SQLite... and all the code has worked before ...but because I couldn't publish the project with the database I have used the System.Data.SQLite
推荐答案
这个问题可能有两个原因。
there can be 2 reasons for this problem.
首先 - 连接到正确的数据库,但没有这样的表。
First - connection is made to the right database but there is no such table there.
第二 - 连接到错误的数据库。在这种情况下,它不给出错误。它使数据库文件在指定的位置。甚至打开数据库。但在获取数据时会出现此错误。在这种情况下,指定的位置将包含一个0 KB的数据库。
Second - connection is made to the wrong database. in such case it gives no error. It makes a database file at the specified location. Even Opens the database. but gives this error when fetching data. In such case the specified location will contain a database of 0 KB.
这篇关于System.Data.SQLite“No such Table”执行Query时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!