求助,请教各位大神一段代码的问题,求帮助
代码如下:
private void aaa_Load(object sender, System.EventArgs e)
{
//产生专业下拉列表
SqlConnection cn = new SqlConnection("Data Source=WIN7U-20151010U;uid=sa;pwd=gsa4tb;Initial Catalog=xsxxdb");
cn.Open();
this.label3.Text = Form1.strLogName;
SqlCommand cmd = cn.CreateCommand();
cmd.CommandText = "select rolename from userinfo where name ='" + label3.Text.ToString() + "'";
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
string temp_role = reader.GetString(0);
this.label5.Text = temp_role;
if (label5.Text == "系统管理员")
{
comboBox1.Text = "门诊部";
}
else if (label5.Text == "操作员")
{
comboBox1.Text = "急诊部";
}
// cn.Close();
}
这段代码的功能是要combobox1中显示出指定的值,但是运行过后combobox中为空,什么都没有,有没有大神能告诉我这是为什吗。。。求帮助啊,真心的