我刚开始着手处理一个样例应用,只需要调用我的SQLite数据库中的一些表格,除此之外我已经解决了其他遇到的问题。但是有一个问题一直困扰着我,尽管我已经搜索了很多,但是对于连接字符串、权限问题等提供的建议都不适用于我。对于权限问题,我添加了“Everyone”用户并授予了完全控制权限,但我仍然遇到同样的错误。
以下是我正在尝试执行的代码:
注意:我使用了以下的汇编语言:
以下是我正在尝试执行的代码:
// calling function
void getRecords2()
{
MySqlLite.DataClass ss = new MySqlLite.DataClass();
DataTable dt = ss.selectQuery("select * from english_words");
}
// the SQLite class that execute the code
using System.Data;
using System.Data.SQLite;
namespace MySqlLite
{
class DataClass
{
private SQLiteConnection sqlite;
public DataClass()
{
//This part killed me in the beginning. I was specifying "DataSource"
//instead of "Data Source"
sqlite = new SQLiteConnection(@"Data Source=C:\testwork\db\MrPick.sqlite3.db;Version=3;FailIfMissing=True");
}
public DataTable selectQuery(string query)
{
SQLiteDataAdapter ad;
DataTable dt = new DataTable();
try
{
SQLiteCommand cmd;
sqlite.Open(); //Initiate connection to the db
cmd = sqlite.CreateCommand();
cmd.CommandText = query; //set the passed query
ad = new SQLiteDataAdapter(cmd);
ad.Fill(dt); //fill the datasource
cmd.Dispose();
sqlite.Dispose();
}
catch (SQLiteException ex)
{
//Add your exception code here.
}
sqlite.Close();
return dt;
}
}
}
注意:我使用了以下的汇编语言:
ADO.NET SQLite Data Provider
Version 1.0.82.0 September 3, 2012
Using SQLite 3.7.14
Originally written by Robert Simpson
Released to the public domain, use at your own risk!
Official provider website: http://system.data.sqlite.org/
非常感谢您在这方面提供的帮助。
C:\testwork\db\MrPick.sqlite3.db
这个文件存在吗?我见过.db3
和.sqlite
的扩展名,但从未见过.sqlite3.db
。 - Bobson