Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Parameter Passing To Sub Reports
Author:
Gehan Fernando
E-mail:
Click to e-mail author
Submitted:
4/17/2007
Version:
VB 2005
Compatibility:
VB 2005, VB 2008
Category:
Databases
Views:
18040
Parameter Passing To Sub Reports And Display In Single Report Using CrystalDecisions In .Net Framework 2.0 [ More Powerful Code - Less CPU Cost]
Declarations:
Option Explicit On Imports CrystalDecisions Imports CrystalDecisions.Shared Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Configuration #Region "About Author" REM Author : Gehan Fernando REM Date : 17-Apr-2007 REM Title : Parameter Passing To Sub Reports And Display In Single Report Using CrystalDecisions In .Net Framework 2.0 REM About : Gehan Fernando Currently Attached To AKLO Information Technologies (Pvt) Ltd, Sri Lanka. REM As Software Developer, Most Of Time He Attached To R.N.D Sites." REM : Code Work 100% REM : Mail - gehan_g7@yahoo.com , charith_c7@yahoo.co.uk
Code:
Public Class FrmReports Private Config As ConnectionStringSettings = ConfigurationManager.ConnectionStrings("SQLServer") Private ConStr As String = Config.ConnectionString() Private Con As System.Data.SqlClient.SqlConnection Private Com As System.Data.SqlClient.SqlCommand Private Prm As System.Data.SqlClient.SqlParameter Private Adap As System.Data.SqlClient.SqlDataAdapter Private Main_DSet As ds_Main Private Sub_DSet As ds_Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Me.Cursor = Cursors.WaitCursor CryView.ReportSource = Nothing Dim Constr As String = "" Dim Config As ConnectionStringSettings = ConfigurationManager.ConnectionStrings("SQLServer") Constr = Config.ConnectionString.ToString() Con = New SqlConnection(Constr) Con.Open() Com = New SqlCommand("PROC_GETEMPLOYEES", Con) Com.CommandType = CommandType.StoredProcedure Adap = New SqlDataAdapter() Main_DSet = New ds_Main() Adap.SelectCommand = Com Main_DSet.Tables("DataTable_Employees").BeginLoadData() Adap.Fill(Main_DSet.Tables("DataTable_Employees")) Main_DSet.Tables("DataTable_Employees").EndLoadData() Main_DSet.Tables("DataTable_Employees").AcceptChanges() Main_DSet.AcceptChanges() Com = New System.Data.SqlClient.SqlCommand("PROC_GETCOMPANY", Con) Com.CommandType = CommandType.StoredProcedure Prm = New System.Data.SqlClient.SqlParameter("@ComCode", SqlDbType.NVarChar, 5, ParameterDirection.Input) Prm.Value = "CM001" Com.Parameters.Add(Prm) Sub_DSet = New ds_Sub() Adap.SelectCommand = Com Sub_DSet.Tables("DataTable_Company").BeginLoadData() Adap.Fill(Sub_DSet.Tables("DataTable_Company")) Sub_DSet.Tables("DataTable_Company").EndLoadData() Sub_DSet.Tables("DataTable_Company").AcceptChanges() Sub_DSet.AcceptChanges() Dim Rpt As New rpt_mainReport() Rpt.SetDataSource(Main_DSet.Tables("DataTable_Employees")) Rpt.Subreports("rpt_subReport.rpt").SetDataSource(Sub_DSet.Tables("DataTable_Company")) CryView.ReportSource = Rpt Adap.Dispose() Main_DSet.Dispose() Sub_DSet.Dispose() Com.Dispose() Con.Dispose() Me.Cursor = Cursors.Default Catch ex As Exception MessageBox.Show(ex.Message, "Error ...", MessageBoxButtons.OK, MessageBoxIcon.Error) Adap.Dispose() Main_DSet.Dispose() Sub_DSet.Dispose() Com.Dispose() Con.Dispose() Me.Cursor = Cursors.Default End Try End Sub End Class
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement