会话在aspx页面中的水晶报表查看器页面的页面加载时到期

时间:2014-07-28 15:49:13

标签: c# asp.net crystal-reports

helo先生,我在报告查看器页面中使用水晶报告版本= 13.0.2000.0它正确显示了所需的报告,但它使当前会话到期,它在cs文件中未到期。我从cs文件中删除了所有会话过期代码,但是不知道get session expire plese在哪里可以告诉我会话在哪里到期,在这种情况下我的代码在下面

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReportViewer.aspx.cs"    Inherits="ReportViewer" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body style="background-color:#69C;" >
   <form id="form1" runat="server">
     <div style=" background-color:Transparent; border-color:Black; border-style:solid; border-width:thin; margin-left:170px; padding:60px; width:900px; height:auto;">
     <br /><br /><br /><center><h2><asp:Label ID="lblhead" runat="server" Text=""></asp:Label></h2></center>
    <table width="850"><tr><td style=" text-align:right;"><asp:LinkButton ID="lnkhome" runat="server">Home</asp:LinkButton></td><td style=" text-align:right;"><b>Welcome :     <asp:Label ID="lbluname" runat="server" Text=""></asp:Label>&nbsp;&nbsp;&nbsp;<asp:LinkButton 
            ID="lnklogout" runat="server" onclick="lnklogout_Click">LogOut</asp:LinkButton></b></td></tr></table>
            <br />
           <hr />          


   <CR:CrystalReportViewer ID="CrystalReportViewer1"  runat="server" 
        AutoDataBind="True"  ReportSourceID="CrystalReportSource1" 
        DisplayStatusbar="False" ToolPanelView="None" PrintMode="ActiveX" />

    <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
 <Report FileName="CrystalReport.rpt" >
</Report>
</CR:CrystalReportSource>




    <asp:Label ID="lbl" runat="server" Text="Label"></asp:Label>
     </div>
    </form>
 </body>
 </html>

cs文件代码==&gt;&gt;

     try
        {
            branchid = Session["branch"].ToString();
            string[] bi = branchid.Split('/');
            branchid = bi[1];
            branchid = branchid.Substring(2, 2);
            if (Session["s"] != null)
            {
                // if (!IsPostBack)
                {
                    rptval = Session["s"].ToString();
                    lbl.Text = rptval.ToString();
                    //Response.Write("<script>alert('" + rptval + "')</script>");
                   ReportDocument reportdocument = new ReportDocument();
                    if (rptval == "Customer Detail")
                    {
                        name = Session["id"].ToString();
                        sodoid = fobj.getvalue("select V_SO_code from Ms_Customer     where                      V_Customer_id='" + name + "'");

                        //  Response.Write("<script>alert('" + name + "')</script>");
                           reportdocument.Load(Server.MapPath("reports/CustomerDetails.rpt"));
                        DataSet1 ds = new DataSet1();
                         DataTable dt = new DataTable();
                        dt.TableName = "Display_Txn_cust_plan_detail";
                        dt = getAllOrders("sp_DisplayCustDetailsRpt");
                        ds.Tables[0].Merge(dt);



                        reportdocument.SetDataSource(ds);

                        // Response.Write("<script>alert('" + sodoid + "')</script>");
                        reportdocument.ParameterFields[0].CurrentValues.Clear();
                       reportdocument.ParameterFields[0].CurrentValues.AddValue(name);
                        reportdocument.ParameterFields[1].CurrentValues.Clear();
                        reportdocument.ParameterFields[1].CurrentValues.AddValue(sodoad);
                         reportdocument.ParameterFields[2].CurrentValues.Clear();
                        reportdocument.ParameterFields[2].CurrentValues.AddValue(sodoid);
                        reportdocument.ParameterFields[3].CurrentValues.Clear();
                         reportdocument.ParameterFields[3].CurrentValues.AddValue("");
                        reportdocument.ParameterFields[4].CurrentValues.Clear();
                        reportdocument.ParameterFields[4].CurrentValues.AddValue("");
                        reportdocument.ParameterFields[5].CurrentValues.Clear();
                        reportdocument.ParameterFields[5].CurrentValues.AddValue("04/04/2014");   
                        reportdocument.ParameterFields[6].CurrentValues.Clear();
                        reportdocument.ParameterFields[6].CurrentValues.AddValue("04/04/2014");


                        //       reportdocument.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "");           //here you can give report file as download as pdf file
                        //Session.Remove("id");
                        //Session.Remove("s");
                    }

  reportdocument.SetDatabaseLogon("uid", "password", "SERVERNAME", "DBNAME");
  CrystalReportViewer1.ReportSource = reportdocument;
        }
        catch (Exception ex)
        {
              String exx = ex.Message;
             Response.Write("<script>alert('" + exx + "')</script>");
            Response.Write("<script>window.location='" + adr + "'; </script>");

        }




    public DataTable getAllOrders(String sp)
    {
        SqlConnection Con = new SqlConnection("User ID=USER;PWD=PASSWORD;server=SERVER;INITIAL CATALOG=DBNAME;PERSIST SECURITY INFO=FALSE;Connect Timeout=0");
        SqlCommand cmd = new SqlCommand();
        DataSet ds = null;
        DataTable dttt = null;
        SqlDataAdapter adapter;
        try
        {
            Con.Open();
            //cmd.CommandText = "sp_DisplayCustDoneInst";
            cmd.CommandText = sp;
            cmd.CommandType = CommandType.StoredProcedure;

            if (sp == "sp_DisplayCustDetailsRpt")
            {
                cmd.Parameters.Add(new SqlParameter("@cust_id", name));
                cmd.Parameters.Add(new SqlParameter("@SO_DO_ADMIN", "Admin"));
                cmd.Parameters.Add(new SqlParameter("@SO_DO_ID", sodoid));
                 cmd.Parameters.Add(new SqlParameter("@OTHER1", ""));
                cmd.Parameters.Add(new SqlParameter("@OTHER2", ""));
                cmd.Parameters.Add(new SqlParameter("@DTOTHER1", "04/04/2014"));
                 cmd.Parameters.Add(new SqlParameter("@DTOTHER2", "04/04/2014"));
            }
cmd.Connection = Con;
            ds = new DataSet();
            dttt = new DataTable();
            adapter = new SqlDataAdapter(cmd);
            adapter.Fill(dttt);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
        finally
        {

        }
        return dttt;

     }

cs和aspx页面代码请帮助我,我的会话即将到期

谢谢

0 个答案:

没有答案