我有一个具有 3 个组合框的 Windows 应用程序。用户名,准备者,授权者。我想要用户名中所有员工的姓名,而在由我准备和授权的情况下,我想要选择的名称,但来自同一个表。所以我在员工表中分配了一个整数值的角色并触发了一个 stroed 过程。我无法填充组合框
SQL:
emp table:
create table emp1
(
employee_id int constraint pk_employee_id_employee primary key not null,
un_id varchar(10) constraint uk_un_id_employee unique not null,
fname varchar(20) not null,
lname varchar(20) not null,
roles int not null
)
stored procedure:
alter proc rolecombo
(
@roles int
)
as begin
select * from emp1 where roles<@roles
end
C#代码:
private void Form1_Load(object sender, EventArgs e)
{
con.Open();
adp = new SqlDataAdapter(cmd);
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "rolecombo";
cmd.Parameters.AddWithValue("@roles",comboBox3.SelectedValue);
adp.Fill(dsautho, "emp1");
comboBox3.DataSource = dsautho.Tables["emp1"];
comboBox3.DisplayMember = "fname";
comboBox3.ValueMember = "employee_id";
comboBox3.SelectedIndex = -1;
con.Close();
}