This is a migrated thread and some comments may be shown as answers.

Adding parameters to DataSource.SelectCommand

1 Answer 148 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 09 Aug 2011, 08:29 AM
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.

1 Answer, 1 is accepted

Sort by
0
danparker276
Top achievements
Rank 2
answered on 09 Aug 2011, 05:09 PM
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.
Tags
General Discussions
Asked by
danparker276
Top achievements
Rank 2
Answers by
danparker276
Top achievements
Rank 2
Share this question
or