Crystal report doesnt work after i make the setup file

c.vaibhav

Member
Joined
May 12, 2009
Messages
22
Programming Experience
Beginner
Hi folks,

I am new to VB.NET.. I have made an application that makes use of crystal report.. I have used the following code..

VB.NET:
   Private Sub InvoicePrint_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'InvoiceNumber = "000005"
        CrystalReportViewer1.ShowRefreshButton = False
        Me.CrystalReportViewer1.ShowGroupTreeButton = False
        CrystalReportViewer1.DisplayGroupTree = False
        Me.WindowState = FormWindowState.Maximized

        Dim ds As DataSet = New DataSet
        myConn = New SqlConnection(ConfigurationManager.ConnectionStrings("default").ToString)
        'Opening Connection
        myConn.Open()

        Dim sadapt As New SqlDataAdapter("Select * from dbo.InvoiceDatabase", myConn)
        sadapt.Fill(ds, "InvoiceDetails")

        'ds.WriteXml("D:\Test\InvoiceDetails.xsd")

        Dim strReportPath As String = Application.StartupPath
        Dim startstring
        startstring = InStr(strReportPath, "bin", CompareMethod.Text)
        strReportPath = strReportPath.Substring(0, startstring - 1)
        strReportPath = strReportPath & "Invoice.rpt"
        'strReportPath = "C:\Users\Vaibhav\Desktop\Windows Applications\Sorbe\Sorbe\CrystalReport1.rpt"
        If Not IO.File.Exists(strReportPath) Then
            Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
        End If
        Dim cr As New Invoice

        cr.Load(strReportPath)
        cr.SetDataSource(ds.Tables("InvoiceDetails"))

        CrystalReportViewer1.ReportSource = cr
        'Me.CrystalReportViewer1.Zoom(150)

        myConn.Close()

    End Sub

I have given the startup path to open the crystal report.. but it doesnt work when I create a setup file.. I know that I am doing a wrong thing.. can anybody please provide a workaround..

Regards,
Vaibhav
 
I got the same problem!

I think that after you create the setup, the .RPT file still tries to get the data from the
original file that you selected when you created the crystal report!

The only problem is that I don't know how to fix this!

I'm still looking for the answer, I'll post it when I've found it.

Greetz
 
Back
Top