Dim tmpWsAssetsManagement As New WsAssetsManagement Dim tmpClsAssetCollection As New List(Of ClsAssetsItemsIndexCard_Record)() Try ' Retrieve asset list from the SQL table using a web service to fill a DataTable Dim tmpClsAssetRecord As New ClsAssetsItemsIndexCard_Record tmpClsAssetRecord.ClsCustomerId = 1000 'ID Dim tmpDtAssetsManagement As DataTable = tmpWsAssetsManagement.AssetsCristalReport_SELECT("00", tmpClsAssetRecord, MyRcError) If Not String.IsNullOrEmpty(MyRcError) OrElse tmpDtAssetsManagement Is Nothing Then ' Handle error cases Throw New Exception("Error Generating Asset Report: " & MyRcError) ElseIf tmpDtAssetsManagement.Rows.Count <= 0 Then ' Handle case when no data is found Throw New Exception("No Data Found To Populate Asset Report.") End If ' Populate the class collection from the datatable retrieved tmpClsAssetCollection = PopulateItemDetailsFromDataTable(tmpDtAssetsManagement) '----- Load your Crystal Report file '------------------------------------------------------------------------------------- Dim rptPath As String = Server.MapPath("~/xxxxx/yyyyy.rpt") Dim rpt As New ReportDocument() rpt.Load(rptPath) ' logon the database CristalReportLogon(rpt) rpt.VerifyDatabase() ' Set the class collection as the report's data source rpt.SetDataSource(tmpClsAssetCollection) ' Set CrystalReportViewer to display the report rptVieverAssetsIndexCard.ReportSource = rpt rptVieverAssetsIndexCard.Visible = True Catch ex As Exception ' Handle exceptions Dim tmpErrorCode As String = "(20000200001-2206-000) " Dim tmpErrorMessage As String = "- Critical Error Generating Asset Report." LblErrorMessage.Text = tmpErrorCode & tmpErrorMessage LblErrorMessage.Attributes.Add("style", "color:red") GlbLogKeepingOperations(tmpErrorCode, {LblErrorMessage.Text, ex.Message, Session("SesUserID").ToString}) Finally ' Clean up resources If Not IsNothing(tmpWsAssetsManagement) Then tmpWsAssetsManagement.Dispose() If Not IsNothing(tmpClsAssetCollection) Then tmpClsAssetCollection = Nothing End Try
rpt.VerifyDatabase()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)