vs2005和sql2000 c#
大家看看这段代码有什么错误吗?我想让name字段中的权限显示到checkboxlist中protectedvoidButton2_Click(objectsender,E...
大家看看这段代码有什么错误吗?我想让name字段中的权限显示到checkboxlist中
protected void Button2_Click(object sender, EventArgs e)
{
string userid = TextBox1.Text.ToString ();
string pwd = TextBox2.Text.ToString();
string mysel = "select name from denglu2 where name='" + userid + "'and pwd='" + pwd + "'";
int k = database.executesql(mysel);
if (k != 0)
{
CheckBoxList1.Enabled = true;
CheckBoxList3.Enabled = true;
string yousel = "select power from powers where name='" + mysel + "'";
int t = database.executesql(yousel);
TextBox5.Text = "用户正确!";
string[] strings = yousel.Split(',');
Hashtable hs = new Hashtable();
for (int i = 0; i < strings.Length; i++)
{ hs.Add(strings[i].ToString(), strings[i].ToString()); }
for (int j = 0; j < CheckBoxList1.Items.Count; j++)
{
for (int i = 0; i < hs.Count; i++)
if (hs.ContainsKey(CheckBoxList1.Items[i].Text))
{ CheckBoxList1.Items[i].Selected = true; }
}
for (int j = 0; j < CheckBoxList3.Items.Count; j++)
{
for (int i = 0; i < hs.Count; i++)
if (hs.ContainsKey(CheckBoxList3.Items[i].Text))
{ CheckBoxList3.Items[i].Selected = true; }
}
}
else { TextBox5.Text = "用户错误,重新输入!"; }
} 展开
protected void Button2_Click(object sender, EventArgs e)
{
string userid = TextBox1.Text.ToString ();
string pwd = TextBox2.Text.ToString();
string mysel = "select name from denglu2 where name='" + userid + "'and pwd='" + pwd + "'";
int k = database.executesql(mysel);
if (k != 0)
{
CheckBoxList1.Enabled = true;
CheckBoxList3.Enabled = true;
string yousel = "select power from powers where name='" + mysel + "'";
int t = database.executesql(yousel);
TextBox5.Text = "用户正确!";
string[] strings = yousel.Split(',');
Hashtable hs = new Hashtable();
for (int i = 0; i < strings.Length; i++)
{ hs.Add(strings[i].ToString(), strings[i].ToString()); }
for (int j = 0; j < CheckBoxList1.Items.Count; j++)
{
for (int i = 0; i < hs.Count; i++)
if (hs.ContainsKey(CheckBoxList1.Items[i].Text))
{ CheckBoxList1.Items[i].Selected = true; }
}
for (int j = 0; j < CheckBoxList3.Items.Count; j++)
{
for (int i = 0; i < hs.Count; i++)
if (hs.ContainsKey(CheckBoxList3.Items[i].Text))
{ CheckBoxList3.Items[i].Selected = true; }
}
}
else { TextBox5.Text = "用户错误,重新输入!"; }
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询