Click here to Skip to main content
14,696,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am just showing crystal report on my webpage using dataset. Crystal report is successfully displaying data in a crystal report. but the problem is that whenever i tried to print. or zoom the crystal report. its prompting that

The report you requested requires further information.

and ask me to give the fallowing informatoin

servername ,databasename , username and password.
Why is it doing that instead of printing or zooming . where is the problem

Here is the code logic. i am just displaying crystal report using dataset.

public partial class _Default : System.Web.UI.Page 
{
    SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString);
    SqlCommand sqlcmd;
    SqlDataAdapter da;
    DataTable dt = new DataTable();
   string sid, query;
   protected void Page_Load(object sender, EventArgs e)
   {
       if (!Page.IsPostBack)
       {
           sid = Request.QueryString["sid"];
           try
           {
               sqlcon.Open();
               //Check whether query string have value or not if not have value then select all record in below query otherwise select particular record with help of where condition
               if (sid == "" || sid == null)
               {
                   query = "select * from student";
               }
               else
               {
                   query = "select * from student where sid='" + sid + "'";
               }
               sqlcmd = new SqlCommand(query, sqlcon);
               da = new SqlDataAdapter(sqlcmd);
               dt.Clear();
               da.Fill(dt);
               if (dt.Rows.Count > 0)
               {
                   ReportDocument RptDoc = new ReportDocument();

                   RptDoc.Load(Server.MapPath("~/CrystalReport.rpt"));
                   RptDoc.SetDataSource(dt);

                   CrystalReportViewer1.ReportSource = RptDoc;
                   CrystalReportViewer1.DataBind();
               }
           }
           catch (Exception ex)
           {
               Response.Write(ex.ToString());
           }
           finally
           {
               sqlcon.Close();
           }
       }
   }
}
Posted
Updated 3-May-12 4:06am
v3

Remove this line and try
if (!Page.IsPostBack)
{
   
Provide Below addtion LogOn information to load crystal report

Private Sub configureCRYSTALREPORT()

Dim myConnectionInfo As New ConnectionInfo()



myConnectionInfo.DatabaseName = "DatabserName"

myConnectionInfo.UserID = "UID"

myConnectionInfo.Password = "PWD"

setDBLOGONforREPORT(myConnectionInfo)

End Sub



Private Sub setDBLOGONforREPORT(ByVal myconnectioninfo As ConnectionInfo)

Dim mytableloginfos As New TableLogOnInfos()

mytableloginfos = CrystalReportViewer1.LogOnInfo

For Each myTableLogOnInfo As TableLogOnInfo In mytableloginfos

myTableLogOnInfo.ConnectionInfo = myconnectioninfo

Next



End Sub
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900