I have the program that runs the following code in the report form.
I also have this code on the remote object that will retreive the data from the server.Code:Private Sub PrintSelectedFK() Dim FK As Integer If C58frmMain.C58ADataGridView.SelectedRows.Count = 0 And C58frmMain.C58ADataGridView.RowCount = 0 And C58frmMain.C58ADataGridView.SelectedCells.Count = 0 Then MessageBox.Show("Update not allowed as no row/cell is selected!", ".NET Remoting Sample", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If 'If cell only is selected, use this to find the UserID If C58frmMain.C58ADataGridView.SelectedRows.Count = 0 And C58frmMain.C58ADataGridView.SelectedCells.Count > 0 Then FK = CType(C58frmMain.C58ADataGridView.Rows(C58frmMain.C58ADataGridView.SelectedCells(0).RowIndex).Cells("FKDataGridViewTextBox").Value, Integer) 'If full row is selected, use this to find the UserID ElseIf C58frmMain.C58ADataGridView.SelectedRows.Count > 0 And C58frmMain.C58ADataGridView.SelectedCells.Count > 0 Then FK = CType(C58frmMain.C58ADataGridView.Rows(C58frmMain.C58ADataGridView.SelectedCells(0).RowIndex).Cells("FKDataGridViewTextBox").Value, Integer) End If 'Define the remote object 'Dim data As RemoteObject.Reports = Nothing 'Dim data As RemoteObject.Reports Dim data As RemoteObject.Reports 'Define a class type and class name of the object you're going to access Dim className As String = "Reports" Dim classType As Type = GetType(RemoteObject.Reports) Try 'Creates a proxy object based on the specific class type & name at the specific address and port data = CType(Activator.GetObject(classType, "tcp://" & Address & ":" & Port.ToString & "/" & className), RemoteObject.Reports) 'Makes a call to a specific function available in the remoting object. 'ReportView.DataSource = data.GetBasicReport 'data.GetBasicReport(CType(MainForm.txtStartDate.Text, Date), CType(MainForm.txtEndDate.Text, Date)) 'Dim userData1 As DataTable = data.PrintC58SelectedFK(FK) Dim userData As DataTable = data.PrintC58SelectedFK(FK) 'Dim userData1 As DataTable = data.PrintC58SelectedFKGoods(FK) 'frmMain.DataGridView.DataSource = userData Dim applicationPath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0).FullyQualifiedName) Dim cr As New ReportDocument 'Dim ds As New DataSet 'ds.Tables.Add(userData) 'ds.WriteXmlSchema(applicationPath & "\UserData.xsd") cr.Load(applicationPath & "\C58Report.rpt") cr.SetDataSource(userData) 'CrystalReportViewer1.ShowRefreshButton = False 'CrystalReportViewer1.ShowCloseButton = False 'CrystalReportViewer1.ShowGroupTreeButton = False CrystalReportViewer1.ReportSource = cr 'MessageBox.Show("Request completed.", ".NET Remoting Sample", MessageBoxButtons.OK, MessageBoxIcon.Information) Catch ex As Exception MessageBox.Show("An unhandled error occured: " & ex.Message, ".NET Remoting Client", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub
The thing is that those two reports individually are working but when they are combine they cannot produce both data as a report with a sub report.Code:Public Function PrintC58SelectedFK(ByVal FK As String) As DataTable 'Implements IUsers.GetAllUsers Dim dt As DataTable = Nothing 'Dim dt1 As DataTable = Nothing Try Console.WriteLine("Get Selected C58 request started at:" & Now.ToString) Dim dal As New DataAccessLayer dt = dal.PrintC58SelectedFK(FK) 'dt1 = dal.PrintC58SelectedFK(FK) dal = Nothing Console.WriteLine("Get Selected C58 request completed at:" & Now.ToString) Catch ex As Exception Console.WriteLine("An unhandled error occured : " & ex.Message) Throw New Exception("An unhandled error occured : " & ex.Message & " in AllUsers") End Try Return dt End Function Public Function PrintC58SelectedFKGoods(ByVal FK As String) As DataTable 'Implements IUsers.GetAllUsers Dim dt1 As DataTable = Nothing Try Console.WriteLine("Get Selected C58 request started at:" & Now.ToString) Dim dal1 As New DataAccessLayer dt1 = dal1.C58PrintSelectedFKGoods(FK) dal1 = Nothing Console.WriteLine("Get Selected C58 request completed at:" & Now.ToString) Catch ex As Exception Console.WriteLine("An unhandled error occured : " & ex.Message) Throw New Exception("An unhandled error occured : " & ex.Message & " in AllUsers") End Try Return dt1 End Function Public Function PrintC58SelectedFKAll(ByVal FK As String) As DataTable 'Implements IUsers.GetAllUsers Dim dt As DataTable = Nothing Try Console.WriteLine("Get Selected C58 request started at:" & Now.ToString) Dim dal As New DataAccessLayer dt = dal.C58PrintSelectedFKAll(FK) dal = Nothing Console.WriteLine("Get Selected C58 request completed at:" & Now.ToString) Catch ex As Exception Console.WriteLine("An unhandled error occured : " & ex.Message) Throw New Exception("An unhandled error occured : " & ex.Message & " in AllUsers") End Try Return dt End Function #End Region Public Function PrintC58SelectedFK(ByVal FK As Integer) As System.Data.DataTable 'Implements IUsers.UserDelete Dim cn As System.Data.SqlClient.SqlConnection = Nothing Dim cmd As System.Data.SqlClient.SqlCommand Dim da As SqlClient.SqlDataAdapter = Nothing Dim dt As DataTable = Nothing Dim dt1 As DataTable = Nothing Try cn = New System.Data.SqlClient.SqlConnection cn.ConnectionString = _connectionString cn.Open() cmd = New System.Data.SqlClient.SqlCommand With cmd .Connection = cn .CommandText = "C58PrintSelectedFK" .CommandType = CommandType.StoredProcedure .CommandTimeout = 30 .Parameters.Add("FK", SqlDbType.Int) .Parameters("FK").Direction = ParameterDirection.Input .Parameters("FK").Value = FK End With dt = New DataTable("C58A") dt1 = New DataTable("C58AGoods") da = New SqlClient.SqlDataAdapter(cmd) da.Fill(dt) da.Fill(dt1) Catch ex As SqlClient.SqlException Throw ex Catch ex As Exception Throw ex Finally If cn IsNot Nothing Then If cn.State = ConnectionState.Open Then cn.Close() End If End Try cn = Nothing Return dt End Function Public Function C58PrintSelectedFKGoods(ByVal FK As Integer) As System.Data.DataTable 'Implements IUsers.UserDelete Dim cn1 As System.Data.SqlClient.SqlConnection = Nothing Dim cmd1 As System.Data.SqlClient.SqlCommand Dim da1 As SqlClient.SqlDataAdapter = Nothing Dim dt1 As DataTable = Nothing Try cn1 = New System.Data.SqlClient.SqlConnection cn1.ConnectionString = _connectionString cn1.Open() cmd1 = New System.Data.SqlClient.SqlCommand With cmd1 .Connection = cn1 .CommandText = "C58PrintSelectedFKGoods" .CommandType = CommandType.StoredProcedure .CommandTimeout = 30 .Parameters.Add("FK", SqlDbType.Int) .Parameters("FK").Direction = ParameterDirection.Input .Parameters("FK").Value = FK End With dt1 = New DataTable("C58AGoods") da1 = New SqlClient.SqlDataAdapter(cmd1) da1.Fill(dt1) Catch ex As SqlClient.SqlException Throw ex Catch ex As Exception Throw ex Finally If cn1 IsNot Nothing Then If cn1.State = ConnectionState.Open Then cn1.Close() End If End Try cn1 = Nothing Return dt1 End Function
Thanks in advance.




Reply With Quote