Hi,
Am getting this error "Object reference not set to an instance of an object". while trying to export crystal report in asp.net 2003 .. Below is my code.
Private Sub ExportClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Go.Click
Try
Dim oStream As New MemoryStream
Me.Crystalreportviewer1.ParameterFieldInfo.Clear()
If Me.txtSTdate.Text.Trim.Length > 0 Then
Me.Crystalreportviewer1.ReportSource = Server.MapPath("pex_Summary.rpt")
Dim ParamFields As ParameterFields = Me.Crystalreportviewer1.ParameterFieldInfo
Dim Per As New ParameterField
Per.ParameterFieldName = "Date"
Dim Period_Value As New ParameterRangeValue
Period_Value.StartValue = Me.txtSTdate.Text
Period_Value.EndValue = Me.txtCLdate.Text
Per.CurrentValues.Add(Period_Value)
ParamFields.Add(Per)
'Set Division Paramter
Dim GetDivisionValues As String
GetDivisionValues = Trim(Request.Form(ddl_division.UniqueID))
Per = New ParameterField
Per.ParameterFieldName = "Division"
Dim Division_Value As New ParameterDiscreteValue
If GetDivisionValues = "Select All" Then
Division_Value.Value = "*"
Else
Division_Value.Value = GetDivisionValues
End If
Per.CurrentValues.Add(Division_Value)
ParamFields.Add(Per)
Select Case DropDownList1.SelectedItem.Text
Case "Rich Text (RTF)"
'-----------------------------------------------------------
oStream = crReportDocument.ExportToStream(_
CrystalDecisions.Shared.ExportFormatType.WordForWindows) ---> Error at this line.
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/rtf"
'------------------------------------------------------------
'------------------------------------------------------------
Case "Portable Document (PDF)"
oStream = crReportDocument.ExportToStream(_
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf"
End Select 'export format
Response.BinaryWrite(oStream.ToArray())
Response.End()
crReportDocument.SetDatabaseLogon("xx", "xx", "xx", "xx") Me.Crystalreportviewer1.RefreshReport()
Crystalreportviewer1.Visible = True
Catch ex As Exception
lblError.Text = ex.Message.ToString
End Try
End Sub
Am getting error at this below line :
oStream = crReportDocument.ExportToStream(_
CrystalDecisions.Shared.ExportFormatType.WordForWindows)
Can anyone pls help me.
Thanks.