我的項目有問題。錯誤 - 沒有給出一個或多個所需參數的值
我試圖從Excel文件讀取數據。當我嘗試選擇大於Col1Value
的行時,但在添加AND Gender = " + gender;
後,它可以正常工作,但它給了我錯誤「沒有爲一個或多個必需參數提供的值」我無法設置特定性別列,因爲它在每個Excel中都不相同文件雖然列名是相同的,當我試圖填充數據集時出現錯誤。
if (boxGender.Text != "")
string gender = boxGender.Text;
string col1Name = lbl1stColumn.Text;
string Query = "select * from [data$] where " +
col1Name + " > " + Col1Value +
" AND Gender = " + gender;
OleDbDataAdapter dacol1 = new OleDbDataAdapter(Query, con);
Column1Data.Clear();
dacol1.Fill(Column1Data)
lblStuCount1Col.Text = Column1Data.Tables[0].Rows.Count.ToString();
當心SQL注入 – arunlalam 2013-05-09 18:19:23
的[我們應包括問題標題標籤(HTTP://meta.stackexchange .com/questions/19190/should-questions-include-tags-in-their-titles)? :不,我們不應該。我們是否應該用** BOLD **來書寫標題? :不,我們不應該。 – phadaphunk 2013-05-09 18:20:51
只有我會使用它:) :) – 2013-05-09 18:20:51