i try to show documents with specific department id

computer-science admin will be able to view only computer-science documents and hr admin view only hr documents

here i create a sp

ALTER procedure [dbo].[sphrdocid1]

     @DepID int
   as
    SELECT DocumentInfo.DocID,
 dbo.DocumentInfo.DocName,
    dbo.DocumentInfo.Uploadfile,
   dbo.DocType.DocType,
   dbo.Department.DepType ,
    dbo.ApproveType.ApproveType AS ApproveID
    FROM dbo.DocumentInfo
       left JOIN dbo.DocType ON dbo.DocumentInfo.DocTypeID=dbo.DocType.DocTypeID
 left JOIN dbo.Department ON dbo.DocumentInfo.DepID=dbo.Department.DepID
    LEFT JOIN dbo.ApproveType ON  
    dbo.ApproveType.approveid=dbo.Department.DepID            
     where    
 dbo.Department.DepID=@DepID



then when i test the query and write this "sphrdocid1 6" it show me like this

 DocID DocDesciption    DocName     Uploadfile       DocTypeID     
    **DepID**                 **UploadedBy**                 UserID

8   paperssSSS  SDASDASD        dsfsdf.docx 1
**4**                      **john**                 **6**

9   hr report   dr reprt n analysis     HR.docx 1
**4**                                   **john**             **6**

and on page load function

GrdFileApprove.DataSource = dd.gethrdoc22(Convert.ToInt32(Session["Userid"]));
            GrdFileApprove.DataBind();

and

 public DataTable hrdoc1(int id)
    {
        return db.ExecuteDataSet("sphrdocid1", new object[] { id }).Tables[0];


    }

when i set a breakpoint it shows me id 0 ..

and when i debug it can not show me any documents in form

where is the probelem?

Recommended Answers

All 3 Replies

Where is hrdoc1 called? Where is id set?

hrdocid1 is sp and id is set in funtion..
DataTable table = db.ExecuteDataSet("sphrdocid1", new object[] { id }).Tables[0];

        return table;

Your trying to turn a DataSet into a Table explicitly which might not work ... try this:

 public DataTable hrdoc1(int id)
{
    DataSet ds = (Call DataSet here)
    DataTable dt = ds.tables[0];
    return dt;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.