You have Store procedure "Get_employee_Info" in Database,
Now
First, you need to get the data from this stored procedure in C#.
Second, you need to Bind the combo box with the data table by setting "Datasource","DataMember" and "ValueMamber".
Steps 1: Get the data into C# from Store procedure:
Copy from this link:
https:
Public DataTable ExecuteDataTable(string storedProcedureName,
params SqlParameter[] arrParam)
{
DataTable dt = new DataTable();
using (SqlConnection cnn = new SqlConnection(
"Data Source=.\sqlexpress;Initial Catalog=AcmeRentals;
Integrated Security=True"))
{
cnn.Open();
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = cnn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = storedProcedureName;
if (arrParam != null)
{
foreach (SqlParameter param in arrParam)
cmd.Parameters.Add(param);
}
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(dt);
}
}
}
return dt;
}
Steps 2: Bind the data table which we get from Stored procedure to combo box.
DataTable empployeeTable = Dac.ExecuteDataTable("Get_Employee_Info", null);
comboBoxEmployee.DataSource = empployeeTable;
comboBoxEmployee.DisplayMember = "EmployeeName";
comboBoxEmployee.ValueMember = "Employee_Id";