C# vs2005 sql2000
publicstaticvoidDropDL(Pagepage,System.Web.UI.ControlCtl){SqlConnectioncon=newSqlConn...
public static void DropDL(Page page, System.Web.UI.Control Ctl)
{
SqlConnection con = new SqlConnection("server=SHENYONGJIA;database=diaocha;uid=sa;pwd=sasa");
con.Open();
int j = 1;
foreach (Control c in Ctl.Controls)
{
if (c is DropDownList)
{
for (int i = 0; i < ((DropDownList)c).Items.Count; i++)
{
if (((DropDownList)c).Items[i].Selected)
{
if (j < 45)
{
string strsql = "update diaocha2 Set s" + i + "=s" + i + "+1 where question_id='" + j + "'";
SqlCommand cmd = new SqlCommand(strsql, con);
cmd.ExecuteNonQuery();
j++;
}
else
{
return;
}
}
}
}
}
con.Close();
}
麻烦看下这个类有没有问题
我是要实现44个dropdownlist都做下面的那个循环 展开
{
SqlConnection con = new SqlConnection("server=SHENYONGJIA;database=diaocha;uid=sa;pwd=sasa");
con.Open();
int j = 1;
foreach (Control c in Ctl.Controls)
{
if (c is DropDownList)
{
for (int i = 0; i < ((DropDownList)c).Items.Count; i++)
{
if (((DropDownList)c).Items[i].Selected)
{
if (j < 45)
{
string strsql = "update diaocha2 Set s" + i + "=s" + i + "+1 where question_id='" + j + "'";
SqlCommand cmd = new SqlCommand(strsql, con);
cmd.ExecuteNonQuery();
j++;
}
else
{
return;
}
}
}
}
}
con.Close();
}
麻烦看下这个类有没有问题
我是要实现44个dropdownlist都做下面的那个循环 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询