Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    3

    Question Unanswered: how can I dynamically assigns parameters to the crystal report

    The Crystal report called a MsSql stored procedure. It requires a parameters.
    In C# program, how can I dynamically assigns parameters to the crystal report which used the MsSql stored procedure?

    Could you show me a solution ?

    volkanaltuntas@yahoo.com
    v.altuntas@gyte.edu.tr
    va01104417@bilmuh.gyte.edu.tr

  2. #2
    Join Date
    Mar 2004
    Posts
    9
    Just check if this wud help.. Ofcourse replace the parameter names withe ur parameter names..


    ParameterDiscreteValue discreteParameter = new ParameterDiscreteValue();
    this.talonReportViewer.Visible = true;

    // Loop through report parameters and set the values
    foreach(ParameterField parameter in report.ParameterFields)
    {
    string parameterName = parameter.ParameterFieldName;
    switch (parameterName)
    {
    case "@BalanceForwardDate":
    discreteParameter.Value = this.dtpBalanceOnForwardDate.Text;
    break;
    case "@StatementDate" :
    discreteParameter.Value = this.dtpStatementOnDate.Text;
    break;

    }
    parameter.CurrentValues.Clear();
    parameter.CurrentValues.Add(discreteParameter);
    }

    // Modify connection information for report
    this.SetConnectionInfo();

    // Show Report
    this.talonReportViewer.ReportSource = report;
    CommonFunctions.SetCursor(CursorMode.Default);

  3. #3
    Join Date
    Mar 2004
    Posts
    3

    stored procedure in crystal repord

    in .net , i use reportdocument component for connect to crystal report. and i cant discover report variable or class which contain a ParameterFields property. and the other problem is this.SetConnectionInfo() expression. this function to cause an error.
    i am beginner for crystal report.
    Could you show me a simple and detailed sample for this problem.
    thanks.

  4. #4
    Join Date
    Mar 2004
    Posts
    9
    We used CrystalDecisions component. So u need to include these
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    to get the classes ParameterDiscreteValue and ParameterField.

    The setConnectionInfo is a method to set the DB connection. Here it goes


    public void SetConnectionInfo()
    {
    // Get new connection informaiton
    ReportSI reportSI = new ReportSI();
    System.Xml.XmlDocument xdoc = reportSI.GetConnectionInfo();
    string serverName = xdoc.SelectSingleNode(@"//server/@value").Value;
    string databaseName = xdoc.SelectSingleNode(@"//dataBase/@value").Value;
    string userID = xdoc.SelectSingleNode(@"//uid/@value").Value;
    string password = xdoc.SelectSingleNode(@"//pwd/@value").Value;

    // Apply new logon information to the report database
    for(int i=0;i<report.Database.Tables.Count;i++)
    {
    // Get current logon and connection information
    TableLogOnInfo logOnInfo = report.Database.Tables[i].LogOnInfo;
    ConnectionInfo connectionInfo = logOnInfo.ConnectionInfo;

    // Change the connection information
    connectionInfo.ServerName = serverName;
    connectionInfo.DatabaseName = databaseName;
    connectionInfo.UserID = userID;
    connectionInfo.Password = password;

    // Apply the new information
    report.Database.Tables[i].ApplyLogOnInfo(logOnInfo);

    if(!report.Database.Tables[i].TestConnectivity())
    {
    //process connection error
    }
    }
    }

    Hope it helps..

  5. #5
    Join Date
    Mar 2004
    Posts
    3

    thanks

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •