views:

8

answers:

1

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);

        }
A: 

Hi guys i got it working ,this what worked for me.Hope this helps someone in the future.

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();
    }
}
Sbee