In my project, I have a button that, when clicked, is supposed to print all contracts that are currently active, from my SQL Server database. There are hundreds of active contracts, but at the moment, when I press the button, the report form loads but the report doesn't.
I'll do my best to demonstrate this using images and code, but is anybody able to suggest why this happens?
// Code for the print button
Private Sub btnPrintActive_Click(sender As Object, e As EventArgs) Handles btnPrintActive.Click
Try
Dim objlist As New ReportDocument
objlist.Load(readIni("REPORTS", directorypath & "connectionpaths.ini") & "\ContractList.rpt")
Dim info As CrystalDecisions.Shared.TableLogOnInfo
info = New CrystalDecisions.Shared.TableLogOnInfo()
info.ConnectionInfo.DatabaseName = ""
info.ConnectionInfo.ServerName = readIni("CONTRACTSTRING", directorypath & "connectionpaths.ini")
info.ConnectionInfo.Password = ""
info.ConnectionInfo.UserID = ""
objlist.Database.Tables(0).ApplyLogOnInfo(info)
objlist.RecordSelectionFormula = "{tblContracts.Agreement} = 'ACTIVE'"
Dim f As frmReports
f = New frmReports(con, acccon, "", 0, "", acccon, , objlist, , )
f.Show()
Catch ex As Exception
errorLog(ex.Message, ex.StackTrace)
MsgBox("Failed to retrieve contract information from 'database', refer to error log")
End Try
End Sub
// This is the report form, but there is no report
// Proof that there are active reports
.rpt
file is where the app is looking for it, and b) thatfrmReports
is loading it? We might need to see the constructor infrmReports
. – Ann L.