the below code accessing the report from the given IP Address... initailly i was facing problem during loading business report from the client computer because the i was used this code
Dim cryRpt As New ReportDocument
cryRpt.Load("D:\Reports\PTC_1.rpt")
on server the above code doing best work because the path is identifing. but from client didn't identify the path.. then i share the folder Reports with readOnly rights so my problem solve because client computer also identify the given path on LAN.
Dim cryRpt As New ReportDocument
cryRpt.Load("\\\Reports\PTC_1.rpt")

But is there any other best way that no need to specify the path and automatically load the reports like loading Forms. anywhere when create a setup file of application and install in client computer

Dani AI

Generated

Short summary: there are two robust ways to avoid hard-coded report paths. Either ship the .rpt files with your installer so each client has a local copy, or keep report generation on the server (generate PDF/HTML there) and send the exported output to clients so they never need the Crystal runtime. As found, a network share works but is brittle (permissions, UNC stability). was right to push the idea of using the app’s deployed paths and changing the report’s data source at runtime — those are the right directions.

Mark each .rpt as project Content (Copy to output) and include the project’s “Content Files” output in your setup project so reports are installed beside the EXE; that removes dependency on a server path. See a simple explanation on packaging content files. (stackoverflow.com)
(How to include content files in output).

Make the Crystal runtime a formal prerequisite: include the correct CR runtime redistributable (CRRedist*.msi) in your installer or chain-install it, and ensure the runtime bitness matches your app’s platform target (x86 vs x64). SAP’s KB explains redistributables and 64-bit deployment caveats. (userapps.support.sap.com)
(CR runtime downloads / KBA).

Avoid writing data into Program Files (UAC/ACLs). Put writable files into ProgramData or per-user AppData and create an app subfolder at install time. When a report references a database, re-point it at runtime (apply TableLogOnInfo or use SetDatabaseLogon / push a DataSet) so the report doesn’t try to open a developer-only path. Microsoft docs cover ApplyLogOnInfo and special-folder usage. ()
().

Quick checklist when a client “can’t load” a report: confirm the .rpt is physically in the installed folder, the correct CR runtime is installed, the app platform target matches the runtime, file ACLs permit read, and the report isn’t still pointing to a design-time DB path. Note that ReportDocument.Load expects a filename (it opens a temp copy), so the installer must place the file where the app looks for it. (learn.microsoft.com)
(ReportDocument.Load details).

don't forget to set your prerequisite on project properties before you build your project and try this code below:

Imports System.Data.OleDb

Public Class Form1

Dim rpt As New CrystalReport1
Dim rpt1 As New CrystalReport2

Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim path1 As String = My.Application.Info.DirectoryPath '' path
'' for normal ADO Concept
'' The current DataSource is an ADO.
Try
'' change path of the database
rpt.DataSourceConnections.Item(0). _
SetConnection("", "" & path1 & "\Xtreme.mdb", False)
'' if password is given then give the password
'' if not give it will ask at runtime
rpt.DataSourceConnections.Item(0).SetLogon("admin", "admin")
cr.ReportSource = rpt '' assign the report to the crytal reprot viewr (cr)
Catch exp As CrystalDecisions.ReportSource.EnterpriseLogonException
MsgBox(exp.Message)
End Try


''%$^%$^$%^$%^$%^$%^$^$^%$^^$%^$^$%^$%^$%^%$^%$^%$^%$^%$^%$^$^$


'' for ADO.Net Concept Using DataSets
'' OLEDB Connection
Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=|DataDirectory|\xtreme.mdb;" & _
"Persist Security Info=True;" & _
"Jet OLEDB:Database Password=admin")
'' SQL Command
'' This command should same as it is in the crystal report file so u just need to copy the
'' code from there
'' Option In crystal Report is Show SQL Query
Dim com As New OleDbCommand("SELECT `Customer`.`Customer Name`, `Customer`.`Postal Code`, " & _
"`Employee`.`FirstName`, `Orders`.`Order Amount`, `Orders`.`Order Date` " & _
"FROM (`Employee` `Employee` " & _
"INNER JOIN `Orders` `Orders` ON " & _
"`Employee`.`EmployeeID`=`Orders`.`Employee ID`)" & _
"INNER JOIN `Customer` `Customer` ON " & _
" `Orders`.`Customer ID`=`Customer`.`Customer ID`")
com.CommandType = CommandType.Text '' command type
com.Connection = con '' give connection to command
Dim adp As New OleDbDataAdapter '' declare adapter
adp.SelectCommand = com '' select command for adpapter to work on
Dim ds As New DataSet '' delcare dataset
adp.Fill(ds, "Crystal") '' fill the dataset through adapter
Try
'' change path of the database for the reprot
'' if not change it will take the old path (if that path exists)
rpt1.DataSourceConnections.Item(0).SetConnection("", "" & path1 & "\Xtreme.mdb", False)
'' if password is given then give the password
'' if not give it will ask at runtime
rpt1.DataSourceConnections.Item(0).SetLogon("admin", "admin")
Catch exp As Exception
MsgBox(exp.Message)
End Try
rpt1.SetDataSource(ds) '' select the Dataset to the source of the report
cr1.ReportSource = rpt1 '' assign the report to the crytal reprot viewr (cr1)
End Sub
End Class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.