我想使用从存储过程到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