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