Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: Object reference not set to an instance of an obje Post Reply Post New Topic
Author Message
yasinirshad
Newbie
Newbie
Avatar

Joined: 24 Sep 2007
Location: Saudi Arabia
Online Status: Offline
Posts: 39
Quote yasinirshad Replybullet Topic: Object reference not set to an instance of an obje
    Posted: 10 Jun 2008 at 11:27am

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.

Thanks,
Yasin.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.