can you help me i have problem with vb.net language.
I want to call crystal report but can't with the data format in gridview sent via crystalreport. with the following code:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim reports As New bpkb_1
reports.SetDataSource(ds.Tables(0))
viewermurabahah.CrystalReportViewer1.ReportSource = reports
viewermurabahah.ShowDialog()
end sub
can you give an example of how the code to call the crystal report file outside of the visual studio vb.net project file?
You can call the load method of the ReportDocument
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rpt.Load(<Path to your crystal report file>)
rpt.SetDataSource(<your data table>)
YouReportViewer.ReportSource = rpt
Related
I am trying to load dummy crystal report document on Form Load so that Crystal Report dll gets loaded in memory.
Private Sub Reports_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim swatch As New Stopwatch
swatch.Start()
Cryload()
swatch.Stop()
Label6.Text = swatch.ElapsedMilliseconds.ToString
End Sub
Private Async Function Cryload() As Task
Dim rpt As New ReportDocument
Await Task.Run(Sub() rpt.Load("Reports\Dummy.rpt"))
End Function
If I run without Crystal Report Document Load the time to load Form is 22 milliseconds.
If I run Cryload() with out Async Load time is 23746 milliseconds.
If I run Cryload() with Async/Await Load time is 14020 milliseconds.
I am sure I am missing something, is there a way to reduce the Form Load time.
Thank you
I am using vs-2012, vb.net for desktop application.
In crystal report I am trying to display total of column (group wise).
In report, grouping is done. But "sum" field/option is not visible in "Running Total Fields". (image attached)
I am using first time "grouping" and "Running Total Fields" in crystal report. So I used a youtube video for a reference. Link- https://www.youtube.com/watch?v=XzPRbOaHG_g
In video at 06:50 there are much more options are visible in list (including sum option), but in my list sum option is not visible and options are less.
Where am I doing wrong?
Actually, I am creating CR from an xml file, not from directly sql database. In below code, I am creating datatable from datagridview, then those values passed to xml file and then I set that xml file as data source of report.
code:
Dim ds_report As New DataSet()
Dim dt_report As New DataTable()
Dim cr As New CrystalReport1()
Private Sub Form7_Load(sender As Object, e As EventArgs) Handles MyBase.Load
set_cr_field()
create_report()
End Sub
Private Sub set_cr_field()
dt_report.Columns.Add("Total Com", GetType(String))
For Each dgr As DataGridViewRow In dgv_report.Rows
Dim total_com as string
total_com = dgr.Cells(25).Value.ToString
dt_report.Rows.Add(total_com)
Next
ds_report.Tables.Add(dt_report)
ds_report.WriteXmlSchema("cr_swastik.xml")
End Sub
Private Sub create_report()
cr.SetDataSource(ds_report)
CrystalReportViewer1.ReportSource = cr
CrystalReportViewer1.Refresh()
End Sub
I have this problem where crystal report is prompting me to enter a value even though I already pass the value from textbox in the vb form.
This is how I create the parameter:
As you can see, I named the parameter NAME.
And here is my code for passing the value from TextBox to parameter NAME in crystal report:
Private Sub indi_print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles indi_print.Click
Dim locatorReport As New report_viewer
Dim rptDoc As CrystalReports.Engine.ReportDocument
rptDoc = New indi_locatorReport 'indi_locatorReport is the Crystal Report
rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLegal
rptDoc.PrintOptions.ApplyPageMargins(New CrystalDecisions.Shared.PageMargins(200, 200, 100, 1500))
rptDoc.SetParameterValue("NAME", name_txtbox.Text)
locatorReport.crptViewer.ReportSource = rptDoc
locatorReport.ShowDialog()
End Sub
When i click the Print Button this is the result:
As you can see Crystal Report prompt me to enter a name. How to fix this?
Try
Dim rptDoc As New indi_locatorReport
rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLegal
rptDoc.PrintOptions.ApplyPageMargins(New CrystalDecisions.Shared.PageMargins(200, 200, 100, 1500))
rptDoc.SetParameterValue("NAME", name_txtbox.Text)
locatorReport.crptViewer.ReportSource = rptDoc
locatorReport.ShowDialog()
I already solved the problem. The problem is whenever the form report_viewer loads, it refreshes the crystal report. It has the Me.crptViewer.RefreshReport() code. I did not notice this because the crystal report viewer created this code.
i created a report and trying to load it to a reportviewer manually but not able to get it loaded .
my code
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ReportViewer1.Reset()
Dim ReportDataSource1 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource
ReportDataSource1.Name = "InvoiceData_DataTable1"
ReportDataSource1.Value = New InvoiceDataTableAdapters.DataTable1TableAdapter().GetData("EBM267")
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(ReportDataSource1)
ReportViewer1.LocalReport.ReportEmbeddedResource = "Billmanagement.report.rdlc"
ReportViewer1.RefreshReport()
End Sub
my Dataset name is InvoiceData
DataTable1 has a parameter billno
which i am supplying for demo but not working please let me know why my report is not loading
a blank report with error is comming
"A datasource instance has not been supplied for the datasource DataSet1"
In Billmanagement.report.rdlc you are using an oject with .DataSetName property set as DataSet1: check every Table/List/Matrix in your report.
I am using VB.NET and MySql and created a report, the report is working without any error on developer machine. It gives following error when I installed it and running on another machine. I have included Microsoft.ReportViewer.Common.dll, Microsoft.ReportViewer.WinForms.dll
This is my code for loading report
Private Sub frmRptCustomerBal_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim cn As New dbConnection
cn.connect()
rptCustomerBalTableAdapter.Connection = cn.conn
ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
ReportViewer1.LocalReport.ReportPath = "rptCustomerBal.rdlc"
Me.rptCustomerBalTableAdapter.Fill(Me.rptCustomerBal._rptCustomerBal)
Me.ReportViewer1.RefreshReport()
cn.close_conn()
End Sub
It looks like you haven't installed Report Viewer on the client system.
Here is the download link for Report Viewer.