2009-07-23 3 views
0

이 코드를 사용하고 SQLite는 말한다 "데이터 소스가 비어있을 수 없습니다 사용합니다. 메모리 : 메모리 데이터베이스를 엽니 다"여기 어댑터 SQLite는 C 번호와 아무것도로드되지

내 코드입니다

string dbfile = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName + "\\m23.db"; 

     string sql; 

     DateTime dt = DateTime.Now; 
     SQLiteConnection connection = new SQLiteConnection("datasource="+ dbfile); 

     SQLiteDataAdapter adapter = new SQLiteDataAdapter("select * from p_posts", connection); 
     DataSet data = new DataSet(); 
     adapter.Fill(data); // <<< here i get the error 

     SQLiteCommand cmd = new SQLiteCommand(); 
     cmd.CommandType = CommandType.TableDirect; 
     cmd.Connection = connection; 

     connection.Open(); 

도움이 필요합니다. 건배!

답변

1

시도

SQLiteConnection connection = new SQLiteConnection("Data Source=" + dbfile); 

examples 내가 본을 사용하는 대신 "데이터 소스"의 "데이터 소스"를 사용.

+0

사용하여 당신은 또한 고려할 수 등의 매개 변수 구문 문제를 방지하려면! ,하지만 지금은 내 테이블 doenst 존재 o.O – Aviatrix

0

SQLiteConnectionStringBuilder

그것은 작동
SQLiteConnectionStringBuilder con = new SQLiteConnectionStringBuilder(); 
con.DataSource = dbfile;