我試圖在gridview中搜索數據庫。當我在文本框中鍵入任何東西我得到這個錯誤:當我在文本框中輸入RowFilter時出現語法錯誤
syntax error missing operand before 'like' operator
這是代碼:
private void txtGrid_TextChanged(object sender, EventArgs e)
{
DataView dv = new DataView(dt);
dv.RowFilter = ""+cbGrid.Text + " like '%" + txtGrid.Text + "%'";
gridPlayers.DataSource = dv;
}
我認爲這可能是'
,但我已經搜索並閱讀所有其他相關問題我能找到。
cbGrid.Text的內容是什麼? – Steve
當'cbGrid.Text'是一個空字符串時,可能是函數觸發。 – gunr2171
您需要爲該字符串構建解析器,以便可以擦除RowFilter的任何「非法」字符。 – krillgar