방금 sqlite 데이터베이스의 일부 테이블을 호출하는 샘플 응용 프로그램을 시작했고,이 문제를 제외하고 나에게 일어난 다른 문제를 해결했습니다. 내가 connectionstring 및 권한 문제에 대한 제안 된 솔루션을 검색하고 모두 나와 함께 유효하지 않은 것 같지만 모든 사용자가 모든 권한과 여전히 같은 오류를 추가했습니다.SQLIte 데이터베이스를 열 수 없습니다.
// 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;
}
}
}
참고 : 아래 난 실행하려고 내 코드는 원래 작성 SQLite는 3.7.14 을 사용하여 2012 년 9월 3일 ADO.NET SQLite는 데이터 공급자 버전 1.0.82.0 : 나는 조립할 수 다음을 사용 에 의해 Robert Simpson 퍼블릭 도메인으로 배포, 사용에 따른 모든 책임은 사용자에게 있습니다! 공식 공급 업체 웹 사이트 : http://system.data.sqlite.org/
정말 고맙습니다.
그래, 예외는 무엇이며 어디에서 가져올 수 있습니까? – cdhowie
당신은 db 3의 버전입니까? –
예외 : System.Data.SQLite.SQLiteException (0x80004005) : 데이터베이스 파일을 열 수 없습니다. – Rama