473,511 Members | 14,990 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 15066
sudarshana
1 New Member
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
1652
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
1802
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
1617
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
2242
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
1934
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
1671
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
2231
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
2229
by: Marcelo | last post by:
Any suggestion? Thanks Marcelo
0
2091
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
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7506
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
5659
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,...
1
5063
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...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.