473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to pass parameter to sub report in crystal report run time?

I am developing web application in VB.net. I want to use crystal reports in my application. I want to add subreports to main report and want to pass parameters to subreports. Can I get sample code to do that?
Jan 17 '08 #1
1 15049
I am developing web application in VB.net. I want to use crystal reports in my application. I want to add subreports to main report and want to pass parameters to subreports. Can I get sample code to do that?

Dim myCon As New SqlClient.SqlConnection()
myCon.ConnectionString = ConfigurationManager.ConnectionStrings("MyCon").Co nnectionString
Dim mycmd As New SqlClient.SqlCommand()
Dim mycmd1 As New SqlClient.SqlCommand
mycmd.Connection = myCon
mycmd1.Connection = myCon
' For Stored Procedure
mycmd.CommandType = CommandType.StoredProcedure
mycmd.CommandText = "Depo_InvoicePrint"
mycmd.Parameters.Add("@CompanyId", SqlDbType.VarChar)
mycmd.Parameters("@CompanyId").Value = Session("CompanyID")

mycmd1.CommandType = CommandType.StoredProcedure
mycmd1.CommandText = "Depo_InvoicePrintSubreport"
mycmd1.Parameters.Add("@DepotID", SqlDbType.VarChar)
mycmd1.Parameters("@DepotID").Value = Session("DepotID")

Dim myda As New SqlClient.SqlDataAdapter()
myda.SelectCommand = mycmd
Dim myDs As New DataSet()
myda.Fill(myDs, "InvoicePrint")

Dim myda1 As New SqlClient.SqlDataAdapter()
myda1.SelectCommand = mycmd1
Dim myDs1 As New DataSet()
myda1.Fill(myDs1, "InvoicePrintSubreport")

mycmd.Dispose()
mycmd1.Dispose()
myCon.Close()

oRpt.Load(Server.MapPath(c:/rptInvoicePrint.rpt"))
oRpt.FileName = Server.MapPath(c:/rptInvoicePrint.rpt")
oRpt.SetDataSource(myDs)
oRpt.OpenSubreport("rptInvoicePrintSub").SetDataSo urce(myDs1)

oRpt.SetParameterValue("@CompanyID", Session("CompanyID"))
oRpt.SetDatabaseLogon(Session("dbuser"), Session("dbpass"))

oRpt.SetParameterValue("@DepotID", Session("DepotID"), "rptInvoicePrintSub")

myCon.Close()
End Sub
Mar 1 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Raj | last post by:
hi, How to pass a Two Date parameter to a report at runtime using VB .NET 1. How do we pass multiple values eg. Startdate, EndDate to crystal reports parameter. 2. I have a report to...
0
by: Michael | last post by:
I followed the solution document at the http://support.businessobjects.com/library/kbase/articles/c2015079.asp?ref=devzone_netzone_howto .. However, the Crystal Report prompt is still showing. The...
0
by: Brenny | last post by:
Hi I'm developing a project and in the project, I used crystal report. Firstly my database isn't protected with password. After finishing project I determined a password for my database. Firstly...
3
by: Don Wash | last post by:
Hi There! I've posted a few days back about this issue but no solutions has been found and that's why I'm re-posting this. I'm using built-in CrystalReport that comes with VS.NET 2003 to...
1
by: Kapil Shah via DotNetMonster.com | last post by:
Hello everybody, I am trying to create a web application to generate Crystal Report with Parameters. However I noticed that ReportDocument.Load is used twice when the parameter page is loaded ....
1
by: Ray | last post by:
Hi all, I would like to ask how to pass a parameter from vb.net to Crystal Report. So I can select a record from SQL database in the Crystal Report. Thanks a lot, Ray
1
by: Ray | last post by:
Dear all, How to pass parameter from vb.net to Crystal Report? I'm now using ReportDocument and CrystalReportViewer. However, I don't know how to pass a parameter to the report and print the...
4
by: Marcelo | last post by:
Any suggestion? Thanks Marcelo
0
by: PriyaManasarovar | last post by:
Can someone help how to pass parameters to a crystal report using a Crystal report object? I am using a console application & hence crystal report viewer cannot be used. And i need to pass the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.