SqlDataSource With Select Parameters

edited October 2009 in FastReport .NET
Hi,

I m trying to use fast report with SqlDataSource object in my ASP.NET project.
When i use SqlDataSource without select parameters, it works. But when i add some select parameters
i get the error below..
some code and stack trace ;

<cc1:WebReport ID="WebReport1" runat="server" ReportDataSources="SqlDataSource1" ReportFile="~/Reports/CRM/Order.frx" ReportResourceString="" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="server=MYSERVER;Initial Catalog=MYDB;uid=MyUser;pwd=MyPass"
SelectCommand="SELECT * FROM [dbo].[vwOrders] WHERE ((@CustomerId IS NULL) OR (CustomerId = @CustomerId)) AND ((@OrderStatus IS NULL) OR (OrderStatus = @OrderStatus)) ">
<SelectParameters>
<asp:QueryStringParameter Name="CustomerId" QueryStringField="customer" Type="Int32" />
<asp:QueryStringParameter Name="OrderStatus" QueryStringField="status" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>


System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at FastReport.Data.Dictionary.HWRMrgXZv(IEnumerable , String , Int32 , Boolean )
at FastReport.Report.UKsHxDq6u(IEnumerable , String )
at FastReport.Report.mgb3BywHV(IEnumerable )
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
at FastReport.Report.RegisterDataAsp(IDataSource data, String name)
at FastReport.Web.WebReport.MQSObcjjN(Report )
at FastReport.Web.WebReport.1fZfqDsN7()
at FastReport.Web.WebReport.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.reports_crm_rptorderstatus_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\mrpweb\9638b2f6\7b3096aa\App_Web_do-pfecj.0.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I m using a custom filter for my web application's report screen.. How can i solve this error?
thanks in advance..

not : i just using latest demo version..

Comments

  • edited 8:20PM
    Hello,

    This can happen if you did not set the parameter value before generating a report. Could you send me an example project?
    tz@fast-report.com
  • edited 8:20PM
    AlexTZ wrote: »
    Hello,

    This can happen if you did not set the parameter value before generating a report. Could you send me an example project?
    tz@fast-report.com

    hi Alex..
    i send a sample asp.net project to your email..
  • edited 8:20PM
    ihsany wrote: »
    hi Alex..
    i send a sample asp.net project to your email..

    any suggestion?
  • edited 8:20PM
    I will review your sample and let you know.
  • edited October 2009
    Hello,

    Since I can't test your example, I made my own. On the main form (Default.aspx) I have a hyperlink that calls another form, WebForm1.aspx. In that form, I have SqlDataSource and WebReport. The hyperlink url that calls the WebForm1, contains parameters:
    ~/WebForm1.aspx?id=2
    

    and SqlDataSource on the WebForm1 uses it:
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:DVDCollectionDatabaseConnectionString %>" 
            SelectCommand="SELECT * FROM [DVDs] WHERE ([ID] = @ID)">
            <SelectParameters>
                <asp:QueryStringParameter DefaultValue="" Name="ID" QueryStringField="id" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
    

    Everything works fine. If I don't include parameter in an url, I will get an error just like your.
  • edited 8:20PM
    I changed my approach and it works now..

    thanks Alex..

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.