Reportviewer Error - vb.net

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.

Related

Calling Crystal Report File

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

Crystal report Viewer keeps on Asking for Logon ID and Password at runtime

Situation:
I made application using vb.net ,ms access and crystal report
When I run it my computer, I don't encounter any problem at all , but when I install and run it on other computer, crystal report asks for login ID and password
I have 2 tables in the report
The main report and the sub report
the Datasource for my rpt file is:
Datasource:C:\User\Documents\report.accdb
some suggests doing something like this:
myreport.SetDatabaseLogon.("user","password")
But I dont know how to use it and where to input the code
Anyone Familiar with this ? Thank you
I just wanted to provide you with the code that I used when I needed to connect to crystal reports embedded within my Visual Studio project.
Please disregard if you are not using the same method.
In my example, I connect to a SQL database so that the stored procedure my crystal report is using can be loaded.
I always used these subroutines to create a crystal report connection and configure the report with proper settings.
I'm not sure if you can set the connectioninfo with just a userID and password, but I figured this code might give you some ideas about what your code is missing.
If you need more help, please provide code snippets so we can help further diagnose.
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
'Crystal Report Here
Private mycrystalreport1 As CrystalReport1
Private Sub ConfigureCrystalReports()
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
mycrystalreport1 = New CrystalReport1()
Dim reportPath As String = Application.StartupPath & "\" & "CrystalReport1.rpt"
mycrystalreport1.Load(reportPath)
CrystalReportViewer1.ReportSource = mycrystalreport1
myConnectionInfo.ServerName = "SQL" 'OR WHATEVER SERVER NAME IS
myConnectionInfo.DatabaseName = "DATABASE_NAME"
myConnectionInfo.UserID = "USER_ID"
myConnectionInfo.Password = "PASSWORD"
SetDBLogonForReport(myConnectionInfo, mycrystalreport1)
End Sub
Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)
Try
Dim myTables As Tables = myReportDocument.Database.Tables
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
myTableLogonInfo.ConnectionInfo = myConnectionInfo
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ConfigureCrystalReports()
'CAN SET PARAMETERS FOR A STORED PROCEDURE OR LOCAL VARIABLES IN CRYSTAL HERE
End Sub
Hopefully, this can provide you with some insight as to how crystal reports can take in a username and password.
Change your report to use ODBC. Makes it easier to check the database connection on each PC.
I'm guessing that the 2nd PC doesn't have the required database drivers to connect to accdb, but that's just a guess.

vb.net Desktop Application not running on a client machine after installation

I have created an application in vb.net using sql server database and crystal reports, I then created the setup file using visual studio 2015 installer extension and installed the project on my Computer from which the application was developed and it is working fine. The issue starts when I install in the client computer, the application does not even start in the client machine, I have installed the .netFramework required and crystal reports run time engine in the client machine but still the app is not starting.
I have a background worker on my startup form and the connection is tested on form load. If the connection is successful the applications the creates a crystal report from a table in the database and if connection is not successful, the application loads the configuration form to manually configure the connection string and a message box will show the exception occurred.
Below is the code
Imports System.ComponentModel
Imports System.Data.SqlClient
Public Class loader
Dim connection As SqlConnection
Private Sub loader_Load(sender As Object, e As EventArgs) Handles MyBase.Load
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
If BackgroundWorker1.CancellationPending Then
e.Cancel = True
Else
ShowPanel([Panel2])
LoaderReportLoading([CrystalReportViewer1])
End If
End Sub
Delegate Sub LoadRpt(ByVal [crv] As Object)
Delegate Sub SetPanelVisible(ByVal [panel] As Panel)
Private Sub LoaderReportLoading(ByVal [crv] As Object) 'use the same delegate LoadRpt
Try
If My.Settings.connection = "" Then
server_configuration.ShowDialog()
Else
connection = New SqlConnection(My.Settings.connection)
connection.Open()
Dim CoTable As New DataTable
Using command As New SqlCommand("SELECT * FROM COMPANY", connection)
Dim adapter As New SqlDataAdapter(command)
adapter.Fill(CoTable)
End Using
Dim rep As New loaderReport
rep.Database.Tables("COMPANY").SetDataSource(CoTable)
If [crv].InvokeRequired Then
Dim myDelegate As New LoadRpt(AddressOf LoaderReportLoading)
Me.Invoke(myDelegate, New Object() {crv})
Else
[crv].ReportSource = rep
End If
connection.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "The following Error Occured While Connecting to the database")
server_configuration.ShowDialog()
End Try
End Sub
Private Sub ShowPanel(ByVal [panel] As Panel)
If [panel].InvokeRequired Then
Dim myDelegate As New SetPanelVisible(AddressOf ShowPanel)
Me.Invoke(myDelegate, New Object() {panel})
Else
[panel].Visible = True
End If
End Sub
End Class
I don't have any idea of using windows event logs, this is my first desktop application to be deployed.
Finally got the error after implementing logging on my system. The error was with the runtime engine for crystal reports. I changed a version of the crystal reports from SP30 to SP26 and all is working fine now.

Error in vb.net ; Is there a way I can open a link using label / button?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim url As String = "www.google.com"
Process.Start(url)
this code seems to show an error:
System.ComponentModel.Win32Exception: 'The system cannot find the file specified.'
This doesn't seem to work?
Process.Start(new ProcessStartInfo("www.google.com") { UseShellExecute
= true}); -- You forgot to mention the UI Platform (assuming WinForms) and the .Net version (assuming .Net Core 3.1 / .Net 5). – Jimi 5 hours
ago
In my case I'm creating a PDF file using iText, and after I've got it saved on disk I do open it using this code:
Process P = new Process();
P.StartInfo.FileName = "C:\\temp\\paquete.pdf";
P.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
P.StartInfo.UseShellExecute = true;
P.Start();
So, I think the main difference between your code and mine is what https://stackoverflow.com/users/14567563/skorture pointed out:
P.StartInfo.UseShellExecute = true;
.NET Core is a bit different than .NET Framework Winforms.
Try adding HTTP or HTTPS to the URL like this
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim url As String = "http://www.google.com"
Process.Start(url)
End Sub

manually load a rdlc report to reportviewer in vb.net

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.