Dim rpt As New ReportDocument()
rpt.Load(Server.MapPath("../Rpt/myReport.rpt"))
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
Dim db = YourClass.GetDatabaseConnection()
crConnectionInfo.ServerName = db.HOST
crConnectionInfo.DatabaseName = db.DBNAME
crConnectionInfo.UserID = db.UID
crConnectionInfo.Password = db.UPWD
CrTables = rpt.Database.Tables
For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
rpt.SetParameterValue("pCustomerID", strCustomerID)
rpt.RecordSelectionFormula = "Formula"
Me.rptCrystal.ReportSource = rpt
Dim cryRpt As New ReportDocument()
Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
cryRpt.Load(MapPath("CrystalReport.rpt"))
crConnectionInfo.ServerName = "ICELand"
crConnectionInfo.DatabaseName = "MiniOPT"
crConnectionInfo.UserID = "sa"
crConnectionInfo.Password = "121212"
CrTables = cryRpt.Database.Tables
For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.RefreshReport()