Please see my code below. It was working fine on my local machine but doesn't work on windows2003 server.
Dim dbFunctions As New DatabaseUtilities
Dim oRpt As ReportDocument
oRpt = New ReportDocument
Dim reportPath As String = Server.MapPath("Medea.rpt")
oRpt.Load(reportPath)
Dim ServerName As String = "MSDB08Q"
Dim DatabaseName As String = "ONBOARD"
Dim userIDName As String = "sa1"
Dim pwdName As String = "pass234"
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
Dim crtableLogoninfos As New TableLogOnInfo
Dim crtableLogoninfo As New TableLogOnInfo
Dim crParameterFieldDefinitions As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions
Dim crParameterFieldDefinition As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue
With crConnectionInfo
.ServerName = ServerName
.DatabaseName = DatabaseName
.UserID = userIDName
.Password = pwdName
End With
CrTables = oRpt.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
CrTable.Location = crConnectionInfo.DatabaseName & ".dbo." & CrTable.Location.Substring(CrTable.Location.LastIndexOf(".") + 1)
Next
crParameterDiscreteValue.Value = Request.QueryString("id")
crParameterFieldDefinitions = oRpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("OBID")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
oRpt.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Landscape
Dim oStream As New MemoryStream 'using System.IO
If Request.QueryString("t") = "pdf" Then
oStream = oRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf" 'vnd.ms-word
Response.BinaryWrite(oStream.ToArray())
Response.End()
Else
oStream = oRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.BinaryWrite(oStream.ToArray())
Response.End()
End If