protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e1)
{
if (e1.CommandName == "BuyClick")
{
Label iid_lbl = (Label)e1.Item.FindControl("iid_lbl");
Label igid_lbl = (Label)e1.Item.FindControl("igid_lbl");
Label iname_lbl = (Label)e1.Item.FindControl("iname_lbl");
Label idesp_lbl = (Label)e1.Item.FindControl("idesp_lbl");
Label iqty_lbl = (Label)e1.Item.FindControl("iqty_lbl");
Label iprice_lbl = (Label)e1.Item.FindControl("iprice_lbl");
Button Button1 = (Button)e1.Item.FindControl("Button1");
str1 = "insert into orders values(' ',' ','" + igid_lbl.Text + "',' ',' ','" + iname_lbl.Text + "',' ')";
str2 = "insert into order_item values(' ','" + iid_lbl.Text + "','" + idesp_lbl.Text + "',' ','" + iprice_lbl.Text + "','" + iqty_lbl.Text + "','" + iname_lbl.Text + "')";
cmd1 = new MySqlCommand(str1, con1);
cmd2 = new MySqlCommand(str2, con1);
cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
con1.Close();
Response.Redirect("buy.aspx");
}
}
错误发生在行 str1 = "insert into orders values(' ',' ','" + igid_lbl.Text + "',' ',' ','" + iname_lbl.Text + "',' ')";