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