2012-03-04 8 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、常にクエリのパラメータを使用してみてください。