I wanted to pass a parameter to stored procedure in crystal reports 10.I have one inculded subreports.without sub report it is working fine .But when we include a sub report (Mapped with Sp) with main report then i am getting an error as Missing Parameter.please help me out . Thanks in advance
Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared Imports System.Security.Principal Imports System.Data Imports System.Web Partial Class Default3 Inherits System.Web.UI.Page Dim crReportDocument As ReportDocument Dim crConnInfo As New ConnectionInfo Protected Sub CrystalReportViewer1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
crReportDocument = New ReportDocument()
Dim rptFields As New ParameterFields()
Dim paramStoreNo As New ParameterField() Dim discreteStoreNo As New ParameterDiscreteValue()
Dim _db_server As String = "Spil232\Rolex" Dim _db_name As String = "Northwind" Dim _user_id As String = "Sprint" Dim _pwd As String = "Sprint"
Dim oSubRpt As New ReportDocument Dim crSections As Sections Dim crSection As Section Dim crReportObjects As ReportObjects Dim crReportObject As ReportObject Dim crSubreportObject As SubreportObject Dim crDatabase As Database Dim crTables As Tables Dim crTable As Table Dim crLogOnInfo As TableLogOnInfo Dim strReportPath As String
strReportPath = "C:\Documents and Settings\vinod.bva\My Documents\Visual Studio 2005\WebSites\WebSite10\CrystalReport8.rpt" crReportDocument.Load(strReportPath)
'log on to SQL server 'Report code starts here 'Set the database and the tables objects to the main report 'oRpt' crDatabase = crReportDocument.Database crTables = crDatabase.Tables 'Loop through each table and set the connection info 'Pess the connection info to the logoninfo object then apply the 'logoninfo to the main report
For Each crTable In crTables With crConnInfo .ServerName = _db_server .DatabaseName = _db_name .UserID = _user_id .Password = _pwd '.IntegratedSecurity = _iSecurity End With crLogOnInfo = crTable.LogOnInfo crLogOnInfo.ConnectionInfo = crConnInfo crTable.ApplyLogOnInfo(crLogOnInfo) If (crTable.TestConnectivity()) Then 'drop fully qualified table location If (crTable.Location.IndexOf(".") > 0) Then crTable.Location = crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1) Else crTable.Location = crTable.Location End If End If 'crTable.LogOnInfo.ConnectionInfo.ServerName = crConnInfo.ServerName Next
paramStoreNo.Name = "@regionId" paramStoreNo.ReportParameterType = ParameterType.ReportParameter paramStoreNo.ParameterValueType = ParameterValueKind.NumberParameter
discreteStoreNo.Value = 1 paramStoreNo.CurrentValues.Add(discreteStoreNo) rptFields.Add(paramStoreNo)
'rptFields.Add(paramStoreNo)
Dim s As String() = {"", ""} Dim index As Integer = 0
CrystalReportViewer1.ReportSource = crReportDocument CrystalReportViewer1.ParameterFieldInfo = rptFields
CrystalReportViewer1.DataBind() CrystalReportViewer1.Visible = True
End Sub End Class
------------- vin
|