使用存储过程选择“查询结果”到DataGridView - DataSet

时间:2017-03-03 08:36:16

标签: c# asp.net stored-procedures

我想使用从存储过程到Datagridview数据源的select查询。 当我运行我的代码时,没有任何反应。我的数据网格视图中没有显示数据。帮助谢谢。

Event:
protected void Emplvl_SelectedIndexChanged1(object sender, EventArgs e)
{
    dgvCategoryList.DataSource = mav.GetCategories2(Emplvl.SelectedValue.ToString());
    dgvCategoryList.DataBind();
}

方法:

    public DataTable GetCategories2(string eelvl2)
{
    SysCon.Open();
    SqlCommand cmdCC = new SqlCommand("sp_SearchEmployeeCategory", SysCon);
    cmdCC.CommandType = CommandType.StoredProcedure;
    cmdCC.Parameters.AddWithValue("@EMPLEVEL", eelvl2);
    SqlDataAdapter daCC = new SqlDataAdapter(cmdCC);
    DataTable dsC = new DataTable();
    daCC.Fill(dsC);
    SysCon.Close();
    return dsC;
}

存储过程:

 ALTER PROCEDURE [dbo].[sp_SearchEmployeeCategory] 
-- Add the parameters for the stored procedure here
@EMPLEVEL NVARCHAR(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

SELECT EmpCategory
FROM tbl_13Month_Computation
WHERE EmpLevel = @EMPLEVEL
END

0 个答案:

没有答案