此代碼中的問題是什麼?在oledbconnection中插入語法錯誤
for (int i = 1; i <= kalanum; i++)
{
foreach (Control ctr in panel1.Controls)
{
if (ctr is TextBox && ctr.Name == i.ToString())
{
int kalaid = int.Parse(((TextBox)ctr).Text);
oleDbCommand1.Parameters.AddWithValue("@k", kalaid);
}
else if (ctr is TextBox && ctr.Name == "tbxfee_" + (i.ToString()))
{
int fee = int.Parse(((TextBox)ctr).Text);
oleDbCommand1.Parameters.AddWithValue("@fe", fee);
}
else if (ctr is TextBox && ctr.Name == "tbxnumber_" + (i.ToString()))
{
int number = int.Parse(((TextBox)ctr).Text);
oleDbCommand1.Parameters.AddWithValue("@n", number);
}
}
oleDbCommand1.CommandText = "INSERT INTO fackala(factornum,kalaid,fee,number) values(@f,@k,@fe,@n)";
oleDbConnection1.Open();
oleDbCommand1.ExecuteNonQuery();
oleDbConnection1.Close();
}
我的訪問文件中的所有列都是數字。當我在表單中插入所有日期併發送表單時,它顯示:
INSERT INTO語句中的語法錯誤。
哪裏是@f'? – 2014-12-02 11:51:52
哪裏是** @ f **參數? – 2014-12-02 11:53:12
它是前循環! – 2014-12-02 11:54:55