[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:
Dim fSalesReportViewer As frmSalesReportViewer = New frmSalesReportViewer
Dim gl_conReport As OleDb.OleDbConnection
Dim ConString As String
ConString = "Provider=sqloledb;Data Source=server;Initial Catalog=test;User Id=sa;Password=;"
gl_conReport = New OleDb.OleDbConnection(ConString)
gl_conReport.Open()
Dim CrReport As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim QueryString As String = "select * from CompanyMaster"
Dim CrAdapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, gl_conReport)
Dim CrDataSet As DataSet = New DataSet
fSalesReportViewer.MdiParent = MainForm
CrAdapter.Fill(CrDataSet)
Dim CrDataTable As DataTable = New DataTable
CrDataTable = CrDataSet.Tables(0)
CrReport.Load(Application.StartupPath & "\Reports\CompanyReport.rpt")
CrReport.Refresh()
CrReport.SetDataSource(CrDataTable)
fSalesReportViewer.ReportViewerSales.ReportSource = CrReport
fSalesReportViewer.Show()
thanks
asm
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..... :wave:
VB Code:
Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
Report.SetParameterValue(0, "Parameter Value")
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
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??
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
Re: Formula in Crystal Report 10
Quote:
but error message shown: "invalid repot file path"
Means Report Path is Incorrect .. Invalid Path Error is not related to the Parameter. ;)
Re: Formula in Crystal Report 10
Hi
VB Code:
'Dim DataSelect As New CrystalDecisions.Shared.ParameterValues
'Dim DataValue As New CrystalDecisions.Shared.ParameterDiscreteValue
'DataValue.Value = "Testing Parameter Value"
'DataSelect.Add(DataValue)
'CrReport.DataDefinition.ParameterFields("CompName").ApplyCurrentValues(DataSelect)
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
Re: Formula in Crystal Report 10
VB Code:
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:
Report.SetParameterValue("ParameterName", "ParameterValue")
Set Parameter :thumb:
Re: Formula in Crystal Report 10
Hi
I have the accordingly but still ask for parameter value while running
VB Code:
'Name -- parameter define in cr reports
CrReport.SetParameterValue("Name", "Test Parameter Value")
Re: Formula in Crystal Report 10
Is your report asking you to feed the value of the name Parameter?
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")
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")
Re: Formula in Crystal Report 10
Quote:
yes , it is asking to feed the value
For which parameter?? Name??
check your Report, I think you are doing something incorrect
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:
CrReport.SetParameterValue("ParamName", "Test Parameter Value") 'Parameter Setting
Re: Formula in Crystal Report 10
Are you using more than one parameter in your crystal report??
VB Code:
'If parameter in the sub report then
Report.Subreports("SubReportName").SetParameterValue("ParameterName", "ParameterValue")
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.
Re: Formula in Crystal Report 10
Read last Post Of the Cr In VB.NET at My signature :thumb:
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.
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... :wave:
Re: Formula in Crystal Report 10
But If i add a subreport in main report than how can i add the table for subreport
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!!
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:
Dim CrReport As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim QueryString As String
Dim CrAdapter As SqlDataAdapter
Dim CrDataTable As DataTable = New DataTable
Dim fSalesReportViewer As frmSalesReportViewer = New frmSalesReportViewer
fSalesReportViewer.MdiParent = MainForm
QueryString = "Select * from EmployeeMaster"
CrAdapter = New SqlDataAdapter(QueryString, gl_Con)
CrAdapter.Fill(CrDataTable)
CrReport.Load(Application.StartupPath & "\Report\EmpTest1.rpt")
CrReport.SetParameterValue("Head", "'Test Head Value'")
fSalesReportViewer.Refresh()
CrReport.SetDataSource(CrDataTable)
fSalesReportViewer.ReportViewerSales.ReportSource = CrReport
fSalesReportViewer.Show()
CrAdapter.Dispose()
CrDataTable.Dispose()
But the while running the report from vb.net it will ask to feed the data .
thanks