Hi
I call the crystal report in vb.net 2003 by below mention method
but it will work if the database is same on which the crystal report
is designed. but if i change the database on runtime then the report will
not display the data from assign database table.
VB Code:
Private Sub cmdprint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdprint.Click Dim fReportViewer As New frmReportViewer Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo fReportViewer.MdiParent = MainForm fReportViewer.Show() Me.Cursor = Cursors.WaitCursor Try CrRepDoc.Load(Application.StartupPath & "\Report\Master\StatusMaster.rpt") CrRepDoc.Refresh() For Each tbCurrent In CrRepDoc.Database.Tables tliCurrent = tbCurrent.LogOnInfo With tliCurrent.ConnectionInfo .ServerName = gl_Server .DatabaseName = gl_DataBase .UserID = gl_User .Password = gl_PassWord End With tbCurrent.ApplyLogOnInfo(tliCurrent) Next tbCurrent fReportViewer.ReportViewerSales.ReportSource = CrRepDoc Catch Exp As Exception MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error") End Try Me.Cursor = Cursors.Default End Sub




Reply With Quote