Adding parameters to DataSource.SelectCommand

2 posts, 0 answers
  1. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 09 Aug 2011 Link to this post

    I'm not sure what's going wrong, but when I set my query programatically, it's not seeing @myParameter is passed into the DataSource.

    On the datasource on my designer, I'm making the parameter as a string and hardcoding it for debugging.  But when I my query runs, the @myParameter passed in is blank.

    I'm using a binding on the report on the DataSource and send it to:

     

     

    public static SqlDataSource ChangeConnectionString(object reportItem, int zoneNo)

     

    {


    dataSource.SelectCommand = ...the query with my parameter



    I set the connection and the query string.  The query string works fine, if I take away the @myParameter.

    I have another report where I do the same thing and it's working fine.  Everything looks the same, but one sets the parameter in the query and the other doesn't.  Anything I should do to debug?  It's really hard because I can't put breakpoints in the code behind.
  2. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 09 Aug 2011 Link to this post

    Ah, I found the difference.  It only works if I have the parameter in my initial select statement.  If I change my select statement programatically, I have to have all the parameters that I use in my initial query that shows up in the designer.
  3. DevCraft banner
Back to Top