View Single Post
  #1 (permalink)  
Old 07-06-2009, 2:17 AM
c.vaibhav c.vaibhav is offline
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: May 2009
Age: 23
Posts: 22
Reputation: 13
c.vaibhav is on a distinguished programming path ahead
Default Crystal report doesnt work after i make the setup file

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..

Code:
   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
Reply With Quote