为什么运行程序时会一次向数据库插入两条相同记录?
代码是这样的:publicintChooseGroup(intGroupID){DBUtility.DBHelpd=newDBUtility.DBHelp();strin...
代码是这样的:
public int ChooseGroup(int GroupID) { DBUtility.DBHelp d = new DBUtility.DBHelp(); string s = Request.QueryString["HDIID"]; int HDIID = Convert.ToInt32(s); string sql = "insert into R_HiddenDangerInstruct_Order (HDIID, GroupID) VALUES ('" + s + "', '" + GroupID + "')"; DataSet ds = d.getDataSet(sql, "R_HiddenDangerInstruct_Order"); return d.exec(sql); }
protected void Button1_Click(object sender, EventArgs e){
for (int i = 0; i < Group.Items.Count; i++)//读取CheckBoxList 选中的值,保存起来 { if (Group.Items[i].Selected) { int GroupID = Convert.ToInt32(this.Group.Items[i].Value.ToString()); ChooseGroup(GroupID); }
}
} 展开
public int ChooseGroup(int GroupID) { DBUtility.DBHelp d = new DBUtility.DBHelp(); string s = Request.QueryString["HDIID"]; int HDIID = Convert.ToInt32(s); string sql = "insert into R_HiddenDangerInstruct_Order (HDIID, GroupID) VALUES ('" + s + "', '" + GroupID + "')"; DataSet ds = d.getDataSet(sql, "R_HiddenDangerInstruct_Order"); return d.exec(sql); }
protected void Button1_Click(object sender, EventArgs e){
for (int i = 0; i < Group.Items.Count; i++)//读取CheckBoxList 选中的值,保存起来 { if (Group.Items[i].Selected) { int GroupID = Convert.ToInt32(this.Group.Items[i].Value.ToString()); ChooseGroup(GroupID); }
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询