0

Please Help, I am creating a Simple Crystal report that views outstanding logs for our call centre,I have a stored procedure that retrieves all the Info I need.Here is where it gets interesting.The Report retrives all the relevant data and shows me page One.When i try to view the second page i get the following " The report you requested requires further information" it then requests Logon Credentials, when i attempt to go to the last Page of the Report i get the following Error"Unable to connect: incorrect log on parameters. " .Using Crystal Viewer i can view my Report ,it has about 50 or so pages when i test with 10 days. I have googled but no all the suggested solutions seem to work
i use the following: SQL Server 2005 Express Edition;VS2008;Crystal reports Version 10.5....
Heres the code i use.
My Connection String looks like this:
I use windows authentication to logon.
Thanks in advance.

"Data Source=ServerName\SQLEXPRESS;Initial Catalog=DBNAME;Integrated Security=True;
try
            {
                CrystalReport1 myRpt = new CrystalReport1();
                CrystalReportViewer1.DisplayGroupTree = false;
                CrystalReportViewer1.DisplayToolbar = true;
                string myConstr = ConfigurationManager.AppSettings["ConnectionString"];
                SqlConnection myConnection = new SqlConnection(myConstr);
                SqlDataAdapter myAdapter = new SqlDataAdapter();
                DataSet1 myDataSet = new DataSet1();
                SqlCommand MyCommand = myConnection.CreateCommand();

                MyCommand.CommandText = "procName";
                MyCommand.CommandType = CommandType.StoredProcedure;
                myAdapter.SelectCommand = MyCommand;
                myAdapter.SelectCommand.Parameters.Add(new SqlParameter("@myPara",Convert.ToInt32(txtDays.Text)));
                myAdapter.Fill(myDataSet, "procName");
                CrystalReportViewer1.ReportSource = myRpt;
                CrystalReportViewer1.DataBind();
            }
            catch (Exception ex)
            {
              string strEX;
               Page.ClientScript.RegisterStartupScript(this.GetType(), "Warning", "alert('Enter Day Criteria Please!!!');", true);
               
            }

Edited by __avd: Added [code] tags.

2
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by samacoba
0

Set DataSource (Instance of DataSet)

myAdapter.Fill(myDataSet, "procName");
 myRpt.SetDataSource(myDataSet);
 CrystalReportViewer1.ReportSource = myRpt;
0

hi there,thanks for your response.I tried your section of code however i still get the same problem.I have noted this however if i use a Page_int event and i do not pass the parameter(txtDays.text) and hardcode any day i want on the Stored Proc, there seems to be no issue in retrieving the relevant info based on the hardcoded days and paging through the data.For me this tells me somehow i am loosing connection to the DB the moment i page the retrieved data.This is very interesting to me .

0

i fixed it for any who might have this in the future heres what worked for me.

public partial class _Default : System.Web.UI.Page
    {
        
        DataSet getRpt()
        {
                CrystalReport1 myRpt = new CrystalReport1();
                string myConstr = ConfigurationManager.AppSettings["ConnectionString"];
                SqlConnection myConnection = new SqlConnection(myConstr);
                SqlDataAdapter myAdapter = new SqlDataAdapter();
                DataSet1 myDataSet = new DataSet1();
                SqlCommand MyCommand = myConnection.CreateCommand();
            try
            {

                CrystalReportViewer1.DisplayGroupTree = false;
                CrystalReportViewer1.DisplayToolbar = true;

                MyCommand.CommandText = "RptPrint";
                MyCommand.CommandType = CommandType.StoredProcedure;
                myAdapter.SelectCommand = MyCommand;
                myAdapter.SelectCommand.Parameters.Add(new SqlParameter("@myDate",Convert.ToInt32(txtDays.Text)));
                myAdapter.Fill(myDataSet, "RptPrint");
                myRpt.SetDataSource(myDataSet);
                CrystalReportViewer1.ReportSource = myRpt;
            }

            catch (Exception ex)
            {
                string strEX;
                strEX = ex.ToString();
                ///Page.ClientScript.RegisterStartupScript(this.GetType(), "Warning", "alert('Enter Day Criteria Please!!!');", true);

            }
            return myDataSet;

        }
        private void Page_Init(object sender, EventArgs e)
        {

            DataSet myD = getRpt();
           
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet myD = getRpt();
        }

        protected void btnPreview_Click(object sender, EventArgs e)
        {
            DataSet myD = getRpt();
          
        }

        protected void CrystalReportViewer1_Init(object sender, EventArgs e)
        {
            
            DataSet myD = getRpt();
        }

        protected void CrystalReportViewer1_Navigate(object source, CrystalDecisions.Web.NavigateEventArgs e)
        {
            DataSet myD = getRpt();
        }
    }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.