|
-
Dec 26th, 2006, 07:26 AM
#1
Thread Starter
Hyperactive Member
[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
-
Dec 26th, 2006, 08:32 AM
#2
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:
Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
Report.SetParameterValue(0, "Parameter Value")
Last edited by shakti5385; Dec 26th, 2006 at 08:36 AM.
-
Dec 27th, 2006, 12:44 AM
#3
Thread Starter
Hyperactive Member
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
-
Dec 27th, 2006, 01:02 AM
#4
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??
-
Dec 27th, 2006, 04:10 AM
#5
Thread Starter
Hyperactive Member
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
-
Dec 27th, 2006, 09:00 AM
#6
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.
-
Dec 29th, 2006, 12:08 AM
#7
Thread Starter
Hyperactive Member
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
-
Dec 29th, 2006, 02:49 AM
#8
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
-
Dec 29th, 2006, 04:37 AM
#9
Thread Starter
Hyperactive Member
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")
-
Dec 29th, 2006, 05:35 AM
#10
Re: Formula in Crystal Report 10
Is your report asking you to feed the value of the name Parameter?
-
Dec 29th, 2006, 06:01 AM
#11
Addicted Member
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
-
Dec 29th, 2006, 06:18 AM
#12
Thread Starter
Hyperactive Member
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")
-
Dec 29th, 2006, 06:29 AM
#13
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
-
Dec 29th, 2006, 07:01 AM
#14
Thread Starter
Hyperactive Member
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
-
Dec 29th, 2006, 07:16 AM
#15
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")
-
Dec 29th, 2006, 07:24 AM
#16
Thread Starter
Hyperactive Member
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.
-
Dec 29th, 2006, 07:26 AM
#17
Re: Formula in Crystal Report 10
Read last Post Of the Cr In VB.NET at My signature
-
Dec 29th, 2006, 07:34 AM
#18
Thread Starter
Hyperactive Member
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.
-
Dec 29th, 2006, 07:41 AM
#19
Re: Formula in Crystal Report 10
 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...
-
Dec 29th, 2006, 07:45 AM
#20
Thread Starter
Hyperactive Member
Re: Formula in Crystal Report 10
But If i add a subreport in main report than how can i add the table for subreport
-
Dec 29th, 2006, 08:04 AM
#21
Re: Formula in Crystal Report 10
 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!!
-
Dec 30th, 2006, 02:10 AM
#22
Thread Starter
Hyperactive Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|