473,668 Members | 2,690 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 15102
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.SqlCo nnection()
myCon.Connectio nString = ConfigurationMa nager.Connectio nStrings("MyCon ").ConnectionSt ring
Dim mycmd As New SqlClient.SqlCo mmand()
Dim mycmd1 As New SqlClient.SqlCo mmand
mycmd.Connectio n = myCon
mycmd1.Connecti on = myCon
' For Stored Procedure
mycmd.CommandTy pe = CommandType.Sto redProcedure
mycmd.CommandTe xt = "Depo_InvoicePr int"
mycmd.Parameter s.Add("@Company Id", SqlDbType.VarCh ar)
mycmd.Parameter s("@CompanyId") .Value = Session("Compan yID")

mycmd1.CommandT ype = CommandType.Sto redProcedure
mycmd1.CommandT ext = "Depo_InvoicePr intSubreport"
mycmd1.Paramete rs.Add("@DepotI D", SqlDbType.VarCh ar)
mycmd1.Paramete rs("@DepotID"). Value = Session("DepotI D")

Dim myda As New SqlClient.SqlDa taAdapter()
myda.SelectComm and = mycmd
Dim myDs As New DataSet()
myda.Fill(myDs, "InvoicePri nt")

Dim myda1 As New SqlClient.SqlDa taAdapter()
myda1.SelectCom mand = mycmd1
Dim myDs1 As New DataSet()
myda1.Fill(myDs 1, "InvoicePrintSu breport")

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

oRpt.Load(Serve r.MapPath(c:/rptInvoicePrint .rpt"))
oRpt.FileName = Server.MapPath( c:/rptInvoicePrint .rpt")
oRpt.SetDataSou rce(myDs)
oRpt.OpenSubrep ort("rptInvoice PrintSub").SetD ataSource(myDs1 )

oRpt.SetParamet erValue("@Compa nyID", Session("Compan yID"))
oRpt.SetDatabas eLogon(Session( "dbuser"), Session("dbpass "))

oRpt.SetParamet erValue("@Depot ID", Session("DepotI D"), "rptInvoicePrin tSub")

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

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

Similar topics

0
1663
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 filter by two dates like FromDate And ToDate
0
1827
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 following are my scenario, the platform, and partial code information. Thanks in advance for the help, Michael J. ------------------------ 1. Scenario: I am trying to pass the parameter value to an embedded Crystal Report file from C#.NET...
0
1624
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 I opened my database as private usage. I determined a database password. Only password, there iso no login ID or user ID. After that, I edited my crystal report.In the crystal report I changed only jet database password. In the report...
3
2248
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 create reports for use it ASP.NET. How do I configure a graph in the Report (*.rpt file) so that I can pass the SQL Query as an argument from ASP.NET Application? I know that I can define
1
1941
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) The first time ReportDocument.Load is used when the Crystal Report is loaded and the parameter page is created. 2) The second time the ReportDocument.Load is again used when the user enters the parameters in the parameters page. My problem is I...
1
1680
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
2239
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 parameter in the report. Please help. Thanks a lot, Ray
4
2243
by: Marcelo | last post by:
Any suggestion? Thanks Marcelo
0
2103
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 parameter through a batch file at run time? I have included a code here to pass parameters, but its giving invalid index error when i try to pass parameters: report1 = app.OpenReport(sfilename) crxDatabase = report1.Database ...
0
8381
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8583
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8656
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6209
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5681
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2791
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1786
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.