locked
Getting clicked hyperlinked text and handling stored procedure prameter issue RRS feed

  • Question

  • User246057125 posted

    I have a Crystal Report in ASP.NET 2.0 [VS-2005] solution. I am struggling with two issues:

    1. I want to retrieve the text using C# when a user clicks on a hyperlinked value on a report using.
    2. I attempted following code to pass a parameter value to a stored procedure and run my Crystal Report. My report is connected to SQL Server stored procedure, which accepts a parameter, @pDistrict.

    On executing below given code, it displays error: "Procedure sp_Report_ShowAllBlocks expects a parameter @pDistrict that was not supplied". Strangely, when I enable SetParameterValue property, it displays error: "No Support".

                ReportDocument rpt = new ReportDocument();
                
                rpt.FileName = @"C:\myProject\rptAllBlocks.rpt";
    
                DataSet ds = new DataSet();
                SqlCommand cmd = new SqlCommand("sp_Report_ShowAllBlocks", dbConnection.cn);
                cmd.Parameters.AddWithValue("@pDistrict", "ABCD");
                cmd.CommandType = CommandType.StoredProcedure;
    
               ParameterField pfieldDistrict = new ParameterField();
               ParameterDiscreteValue disValDistrict = new ParameterDiscreteValue();
               disValDistrict.Value = "ABCD";
               pfieldDistrict.Name = "@pDistrict";
               pfieldDistrict.CurrentValues.Add(disValDistrict);
               //rpt.ParameterFields.Add(pfieldDistrict);
               
               rpt.SetParameterValue("@pDistrict", disValDistrict.Value.ToString());
               
                SqlDataAdapter da = new SqlDataAdapter(cmd.CommandText, dbConnection.cn);
               da.Fill(ds);
    
                rpt.SetDataSource(ds);
    
                CrystalReportViewer1.ReportSource = rpt;
    



    Tuesday, September 27, 2011 11:08 PM

Answers