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:
  1. Private Sub cmdprint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdprint.Click
  2.         Dim fReportViewer As New frmReportViewer
  3.         Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
  4.         Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
  5.         fReportViewer.MdiParent = MainForm
  6.         fReportViewer.Show()
  7.         Me.Cursor = Cursors.WaitCursor
  8.         Try
  9.             CrRepDoc.Load(Application.StartupPath & "\Report\Master\StatusMaster.rpt")
  10.             CrRepDoc.Refresh()
  11.             For Each tbCurrent In CrRepDoc.Database.Tables
  12.                 tliCurrent = tbCurrent.LogOnInfo
  13.                 With tliCurrent.ConnectionInfo
  14.                     .ServerName = gl_Server
  15.                     .DatabaseName = gl_DataBase
  16.                     .UserID = gl_User
  17.                     .Password = gl_PassWord
  18.                 End With
  19.                 tbCurrent.ApplyLogOnInfo(tliCurrent)
  20.             Next tbCurrent
  21.             fReportViewer.ReportViewerSales.ReportSource = CrRepDoc
  22.         Catch Exp As Exception
  23.             MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
  24.         End Try
  25.         Me.Cursor = Cursors.Default
  26.     End Sub