2012-03-04 2 views
0

문제를 해결하는 방법을 모르겠습니다. 요청 된 데이터 레코드를 DataGrid에 제공해야하는 sqlite 쿼리입니다. 번호를 입력하면 작동합니다! 하지만 편지를 입력 할 때가 아닙니다.Sqlite 오류 (DataGrid)

SQLite는 오류 이러한 열 : 예

내 코드 : 당신이 예 테이블 목록에 있는지 확인하고 그 유형이 CHAR, NVARCHAR 또는 기타의 경우

SQLiteConnection connection = new SQLiteConnection(); 
       connection = new SQLiteConnection("Data Source=Database.s3db;Version=3;New=False;Compress=True;"); 
       SQLiteCommand command = new SQLiteCommand(connection); 
       SQLiteDataAdapter DB; 
       DataSet DS = new DataSet(); 
       DataTable DT = new DataTable(); 
       connection.Open(); 

       command = connection.CreateCommand(); 
       string CommandText = "select Example from Lists where Example =" + textBox.Text ; 
       DB = new SQLiteDataAdapter(CommandText, connection); 
       DS.Reset(); 
       DB.Fill(DS); 
       DT = DS.Tables[0]; 
       Grid.DataSource = DT; 
       connection.Close(); 

답변

1

문자 유형 다음에 TextBox.Text를 작은 따옴표로 묶으십시오.

select Example from Lists where Example ='" + textBox.Text +"'" ; 

Ho wever, 항상 쿼리에서 매개 변수를 사용하십시오.