Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
CrystalReportViewer1.Load
Dim cryRpt As New ReportDocument
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
With crConnectionInfo
.ServerName = ConfigurationManager.AppSettings(“ServerName”) 'YOUR SERVER NAME"
.DatabaseName = ConfigurationManager.AppSettings(“MainData”) 'YOUR DATABASE NAME"
.UserID = ConfigurationManager.AppSettings(“User_ID”) 'YOUR DATABASE USERNAME"
.Password = ConfigurationManager.AppSettings(“Password”) 'YOUR DATABASE PASSWORD"
End With
Dim ReportName As String = “cons.rpt”
ReportName = Application.StartupPath & “\” & ReportName & “”
Dim ReportForm As CrystalDecisions.CrystalReports.Engine.ReportDocument = New
CrystalDecisions.CrystalReports.Engine.ReportDocument
ReportForm.Load(ReportName)
CrTables = ReportForm.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
CrystalReportViewer1.ReportSource = ReportForm
CrystalReportViewer1.Refresh()
End Sub
i hve made a application in vs2005 which has crystal report
in my system i have VS2005 software
crytsal report whetver i needed i hve done it a design time ie added the fields needed during design time
i had placed all the reports in folder knw as reports & had given the path accordingly
when i first executed the app;lication & tried to view the report i got a msg something like " reports cann not be displayed , & needs to be in the bin folder of the application"
so i pasted all the reports frm report folder in bin & now its working
- i published my application as i wanted to run it on a client system which didnot have VS2005 software
i had just installed teh framework & crystal report MSI file
i deployed the published application along with reports folder
i made necesasry changes in app.config file to specify the client server & database
my application is working fine but when i try to view the reports it showed me a login dialog box which contained the servername, username & password
though in config file i had specified clinet servername it took the server name of my system & asked for password
so after going thr’ net i got the above code for deploying crystal report on clinet