存储过程正在执行但无法填充gridview

时间:2021-09-06 02:05:25

I need to populate a gridview upon user login. I have written a stored procedure for populating that gridview using login credentials... my stored procedure is working ... I'm able to get the output in SQL Server but once I use login id and password and logs in gridview isn't getting populated... please help me out..

我需要在用户登录时填充gridview。我已经编写了一个存储过程,用于使用登录凭据填充该gridview ...我的存储过程正在运行...我能够在SQL Server中获取输出但是一旦我使用登录ID和密码并且gridview中的日志不是人口稠密......请帮帮我..

This is my codes and stored procedure

这是我的代码和存储过程

Stored procedure:

存储过程:

ALTER PROCEDURE [dbo].[GetManager]
    @EmpName nvarchar(50)
AS
  SELECT
      TaskName, DueDate, Description, AssignBy, AssignTo, Status, PercentageComplete
  FROM
      dbo.Task, dbo.EmployeeData
  WHERE
      AssignTo IN (SELECT EmpName FROM EmployeeData WHERE Manager = 'RS') 
      AND AssignBy IN (SELECT EmpName FROM EmployeeData WHERE Manager = 'RS')
      AND EmpName = @EmpName;

I'm using 3 layered architecture.. wich has DTO,DAL and business layer.. I'm calling data source through these layers.

我正在使用3层架构..它有DTO,DAL和业务层..我通过这些层调用数据源。

Backend code

后端代码

DAL :

DAL:

public DataSet GetManager(MTMSDTO M)
{
        DBAccess db = new DBAccess();
        SqlParameter objParam = new SqlParameter("@EmpName", M.EmpName);
        objParam.Direction = ParameterDirection.Input;
        objParam.Size = 50;

        db.Parameters.Add(objParam);
        return db.ExecuteDataSet("GetManager");
} 

BusinessLayer :

BusinessLayer:

public DataSet GetManager(MTMSDTO M)
{
        MTMSAccess obj = new MTMSAccess();
        return obj.GetManager(M);
}

Gridview calling function using stored procedure:

Gridview调用函数使用存储过程:

protected void GrdManager()
{
           MTMSDTO objc = new MTMSDTO();
           {
            objc.EmpName = Convert.ToString(Session["EmpName"]);
            DataSet GrdMA = obj.GetManager(objc);
            DataView GrdMan = new DataView();
            GrdMan.Table = GrdMA.Tables[0];
            GridViewTTlist.DataSource = GrdMan;
            GridViewTTlist.DataBind();
           }
}

1 个解决方案

#1


1  

try this

尝试这个

protected void GrdManager()
{
           MTMSDTO objc = new MTMSDTO();

            objc.EmpName = Convert.ToString(Session["EmpName"]);
            DataSet GrdMA = obj.GetManager(objc);
            GridViewTTlist.DataSource = GrdMA.Tables[0];
            GridViewTTlist.DataBind();

}

#1


1  

try this

尝试这个

protected void GrdManager()
{
           MTMSDTO objc = new MTMSDTO();

            objc.EmpName = Convert.ToString(Session["EmpName"]);
            DataSet GrdMA = obj.GetManager(objc);
            GridViewTTlist.DataSource = GrdMA.Tables[0];
            GridViewTTlist.DataBind();

}