Results 1 to 22 of 22

Thread: [RESOLVED] Formula in Crystal Report 10

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Resolved [RESOLVED] Formula in Crystal Report 10

    Hi

    How can I pass the formula in Crystal Report 10 in VB.Net. Without formula I am using this method to call the crystal report.

    Can anybody guide me how to pass the formula :
    VB Code:
    1. Dim fSalesReportViewer As frmSalesReportViewer = New frmSalesReportViewer
    2. Dim gl_conReport As OleDb.OleDbConnection
    3. Dim ConString As String
    4. ConString = "Provider=sqloledb;Data Source=server;Initial Catalog=test;User Id=sa;Password=;"
    5. gl_conReport = New OleDb.OleDbConnection(ConString)
    6. gl_conReport.Open()
    7. Dim CrReport As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
    8. Dim QueryString As String = "select * from CompanyMaster"
    9. Dim CrAdapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, gl_conReport)
    10. Dim CrDataSet As DataSet = New DataSet
    11. fSalesReportViewer.MdiParent = MainForm
    12. CrAdapter.Fill(CrDataSet)
    13. Dim CrDataTable As DataTable = New DataTable
    14. CrDataTable = CrDataSet.Tables(0)
    15. CrReport.Load(Application.StartupPath & "\Reports\CompanyReport.rpt")
    16. CrReport.Refresh()
    17. CrReport.SetDataSource(CrDataTable)
    18. fSalesReportViewer.ReportViewerSales.ReportSource = CrReport
    19. fSalesReportViewer.Show()

    thanks

    asm

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Formula in Crystal Report 10

    It is batter for you that use the parameter for passing the value in the crystal report. See the code for parameter
    make a parameter in your report then.....

    VB Code:
    1. Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
    2. Report.SetParameterValue(0, "Parameter Value")
    Last edited by shakti5385; Dec 26th, 2006 at 08:36 AM.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Re: Formula in Crystal Report 10

    Hi
    I change the report and add parameter (name) and pass the parameter in vb.net
    like: CrReport.SetParameterValue(0, "Company Details")
    but error message shown: "invalid repot file path"

    thanks

  4. #4
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Question Re: Formula in Crystal Report 10

    Error showing it self that report path is not correct, check the report path is it at the location or not??

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Re: Formula in Crystal Report 10

    no, path of report is correct, if i remove the parameter than it work properly
    and when i include the paramenter this error shown


    thanks

  6. #6
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Wink Re: Formula in Crystal Report 10

    but error message shown: "invalid repot file path"
    Means Report Path is Incorrect .. Invalid Path Error is not related to the Parameter.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Re: Formula in Crystal Report 10

    Hi

    VB Code:
    1. 'Dim DataSelect As New CrystalDecisions.Shared.ParameterValues
    2. 'Dim DataValue As New CrystalDecisions.Shared.ParameterDiscreteValue
    3. 'DataValue.Value = "Testing Parameter Value"
    4. 'DataSelect.Add(DataValue)
    5. 'CrReport.DataDefinition.ParameterFields("CompName").ApplyCurrentValues(DataSelect)
    6. CrReport.SetParameterValue(0, "Test Parameter Value")

    When run the system , it will ask the parameter value but i want to set the parameter value from code / get the information from form

    Pls guide how to do this

    thanks

    asm

  8. #8
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Formula in Crystal Report 10

    VB Code:
    1. CrReport.SetParameterValue(0, "Test Parameter Value")
    In above code Zero means thet the we are setting the first parameter value. So How many parameter you are using in your Report. You have to set the value of Parameter according to the Parameter Index.You can pass the parameter value according to the Parameter Name also. Like This
    VB Code:
    1. Report.SetParameterValue("ParameterName", "ParameterValue")
    Set Parameter

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Re: Formula in Crystal Report 10

    Hi
    I have the accordingly but still ask for parameter value while running
    VB Code:
    1. 'Name -- parameter define in cr reports
    2.         CrReport.SetParameterValue("Name", "Test Parameter Value")

  10. #10
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Formula in Crystal Report 10

    Is your report asking you to feed the value of the name Parameter?

  11. #11
    Addicted Member mabbas110's Avatar
    Join Date
    Oct 2005
    Location
    Karachi , Pakistan
    Posts
    172

    Re: Formula in Crystal Report 10

    Suppose the formula field name is "vbforums" and the value is "verygood" then it would be

    CrReport.SetParameterValue("vbforums", "verygood")
    Thanks and Regards,

    Muhammad Abbas

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Re: Formula in Crystal Report 10

    yes , it is asking to feed the value

    Parameter name is "Name" and the value is "Test Parameter Value"

    CrReport.SetParameterValue("Name", "Test Parameter Value")

  13. #13
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Question Re: Formula in Crystal Report 10

    yes , it is asking to feed the value
    For which parameter?? Name??

    check your Report, I think you are doing something incorrect

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Re: Formula in Crystal Report 10

    I change the crystal report parameter name to "ParamName"
    But the problem is still remains .. it will ask to feed the data while running the report from vb.net.
    VB Code:
    1. CrReport.SetParameterValue("ParamName", "Test Parameter Value")                 'Parameter Setting

  15. #15
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Formula in Crystal Report 10

    Are you using more than one parameter in your crystal report??
    VB Code:
    1. 'If parameter in the sub report then
    2.         Report.Subreports("SubReportName").SetParameterValue("ParameterName", "ParameterValue")

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Re: Formula in Crystal Report 10

    No, I am trying on main report there is no subreport.

    Now I am creating a report in Cr which is contains more than one table but the problem is -- how can i define the table in vb.net for every table i used in cr.

  17. #17
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Formula in Crystal Report 10

    Read last Post Of the Cr In VB.NET at My signature

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Re: Formula in Crystal Report 10

    You means to say that i have create each tables in dataset by there names i add in crystal report.

  19. #19
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Lightbulb Re: Formula in Crystal Report 10

    Quote Originally Posted by asm
    You means to say that i have create each tables in dataset by there names i add in crystal report.
    Ya I am doing in this way...

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Re: Formula in Crystal Report 10

    But If i add a subreport in main report than how can i add the table for subreport

  21. #21
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Formula in Crystal Report 10

    Quote Originally Posted by asm
    But If i add a subreport in main report than how can i add the table for subreport
    You are correct,but I am working on the sub report Also but it will take some times!!

  22. #22

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Re: Formula in Crystal Report 10

    Ok,
    But the still i face the parameter value problem .. In parameter fileds -- add "Head"
    and drap it to the report section, In report section it will show "?Head". I am not change any properties of format fields of "?Head". And call it in vb.net
    VB Code:
    1. Dim CrReport As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
    2.         Dim QueryString As String
    3.         Dim CrAdapter As SqlDataAdapter
    4.         Dim CrDataTable As DataTable = New DataTable
    5.         Dim fSalesReportViewer As frmSalesReportViewer = New frmSalesReportViewer
    6.         fSalesReportViewer.MdiParent = MainForm
    7.         QueryString = "Select * from EmployeeMaster"
    8.         CrAdapter = New SqlDataAdapter(QueryString, gl_Con)
    9.         CrAdapter.Fill(CrDataTable)
    10.         CrReport.Load(Application.StartupPath & "\Report\EmpTest1.rpt")
    11.         CrReport.SetParameterValue("Head", "'Test Head Value'")
    12.         fSalesReportViewer.Refresh()
    13.         CrReport.SetDataSource(CrDataTable)
    14.         fSalesReportViewer.ReportViewerSales.ReportSource = CrReport
    15.         fSalesReportViewer.Show()
    16.         CrAdapter.Dispose()
    17.         CrDataTable.Dispose()

    But the while running the report from vb.net it will ask to feed the data .

    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
  •  



Click Here to Expand Forum to Full Width