Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change datasource based on parameter

Status
Not open for further replies.

stnkyminky

Programmer
Oct 15, 2001
476
US
My company has multiple divisions. I'd like to give the client the option to run the report for the division of their choice based on a parameter. I'm really being lazy here and would like to write 1 report instead of 3.

Thanks for your help

Scott
Programmer Analyst
<{{><
 
Scott,

First, the bad news.

You can't use (as far as I know) a parameter to change a data set.

Now the good news.

You can create a single dataset with an If Else statement that changes what Data gets accessed based on what the parameter is. Here's the example I used when giving users the choice of "All Tables & all their columns", "One table & all its columns" and "One table and one column":

Code:
If @tblName = 'All Tables'
  Begin
      Exec ddsp_AllColumnDetails2  @AllTablesName      
  End

Else	
   if @tblName <> 'All Tables' and @colName = 'All Columns'
    Begin
       Exec ddsp_AllColumnDetails1 @tblName
    End
Else
    If  @tblName <> 'All Tables' and @colName <> 'All Columns' 
     Begin      
       Exec ddsp_AllColumnDetails @tblName, @colName
     End

Of course, I sent the parameter to execute a stored procedure (rather than executing my query right there) which pulled up the appropriate data based on the parameter.

Does this help?



Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
That's definitely an interesting solution. I'll try it out and let you know what happens.


Thanks

Scott
Programmer Analyst
<{{><
 
I 'm working on a small application when I publish all my reports ,but I also have a shared datasource
I don't want to create a new also just publish my shared datasource.
Some body could help me
Thanks
 
Nvegamarrero,

Not sure exactly what you're asking. You're talking about DataSource, which is a completely different animal than a dataset. What exactly is your question?



Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top