Hi,
Please note that you are not opening connection in your program. Update the below code
SqlConnection conn = new SqlConnection(con);
conn.Open();
SqlCommand cmd = new SqlCommand("spGettblInvoiceReport");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@invno", SqlDbType.Int).Value = Convert.ToInt16(Request.QueryString["invno"]);
cmd.Parameters.Add("@companyid", SqlDbType.Int).Value = Convert.ToInt16(Session["companyid"].ToString());
DataSet dsInv = ems.Make_Ds(cmd, conn);
SqlCommand cmd1 = new SqlCommand("spGetTblInvoicedetailsReport");
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.Add("@invno", SqlDbType.Int).Value = Convert.ToInt16(Request.QueryString["invno"]);
cmd1.Parameters.Add("@companyId", SqlDbType.Int).Value = Convert.ToInt16(Session["companyid"].ToString());
DataSet dsPRD = ems.Make_Ds(cmd1, conn);
And your coading is very bad. You are using values from query string and session but even not checking for null values.
Your function should not be this big.
Follow the below link for coading standard.
http://www.tiobe.com/content/paperinfo/gemrcsharpcs.pdf[
^]