Pass a value to SQL parameter

3 posts, 0 answers
  1. Craig
    Craig avatar
    20 posts
    Member since:
    Aug 2006

    Posted 25 Oct 2012 Link to this post

    I am Having a really difficult time with this, it seems like it should be so simple. I wish there were better/more complete examples. It seems a lot of post about this but not a lot of info.

    Here is what I am trying to do. I have an aspx page with a report viewer control. I have a simple report built in it's own class that has a SqlDataSource. The SqlDataSorce have one parameter for the record ID. In my aspx page I get a QueryString for the records ID and want to pass it to the SqlDataSource. I have tried both the Report Parameter method and trying to pass straight to the SqlDataSource.

    Here is my code in my report that sets the SQL Param:
    Public Property Param1() As Integer
                Return DirectCast(Me.SqlDataSource1.Parameters("@wo_id").Value, Integer)
            End Get
            Set(ByVal value As Integer)
                Me.SqlDataSource1.Parameters("@wo_id").Value = value
            End Set
        End Property

    And Here is what I have on my aspx page:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim wo_id As String = Request("wo")
    Dim rpt = New WorkRequestRpt()
    Dim instanceReportSource = New Telerik.Reporting.InstanceReportSource()
    instanceReportSource.ReportDocument = rpt
    rpt.Param1 = CInt(wo_id)
    Me.ReportViewer1.ReportSource = instanceReportSource 'New WorkRequestRpt()
    End Sub

    This is slight different than the examples I saw because I kept getting an error that certain methods were now obsolete.

    Every time I open the report it is just blank. I don't know if I need to use the Need_DataSource event or what. Also, do I need some parameter on the report? If I remove the parameter and just have a straight query it work fine. Something is not passing the vale to the SqlDataSource.

    A real good example with all of the steps would be great (the video is hard to follow, especially with some of the methods becoming obsolete). I think it would also help a lot of other out.

  2. Craig
    Craig avatar
    20 posts
    Member since:
    Aug 2006

    Posted 26 Oct 2012 Link to this post

    This is now working! It turns out that that the code was OK. It seems that at some point in the blurry eyed hours I set the ReportViwer to 100% height and width. For whatever reason it wasn't showing the report. Once I reduced the control size the report shows and works as expected.

    Now I am off to find out why a report wont show if it's set to 100% height and width.

  3. DevCraft R3 2016 release webinar banner
  4. IvanY
    IvanY avatar
    417 posts

    Posted 30 Oct 2012 Link to this post

    Hello Craig,

    We were not able to reproduce the issue with the size of the Report Viewer at our end. From your description it seems that the viewer was not able to adjust its height - this usually can happen if it is not visible initially (for example if it is contained in a tab), but in your case may be caused by some styles that cause overlapping and the calculation of the height goes wrong.

    You can check our samples that get installed along with the product (located in Start -> Telerik -> Reporting Q3 2012 -> Visual Studio 2010 Examples -> C# Solution) - the Report Viewer height and width are set to 99%, but setting them to 100% does not cause any issues.

    the Telerik team

    HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Back to Top