Showing posts with label parameter. Show all posts
Showing posts with label parameter. Show all posts

Thursday, March 29, 2012

Embedding a Report Within Page

Ok, I am getting extremely frustrated here, so I hope someone can help me.

I am trying to pass a parameter to a reportviewer control that is supposed to run a server report. This is how I am doing this:

Dim serverParams(0) As ReportParameter
serverParams(0) = New ReportParameter("RMAID", "3")
Me.RMAReport.ServerReport.ReportServerUrl = New Uri("http://MEDUSA/reportserver")
Me.RMAReport.ServerReport.ReportPath = "/CustomerServiceReports/RMAListingsById"
Me.RMAReport.ServerReport.SetParameters(serverParams)
Me.RMAReport.ServerReport.Refresh()


Now as far as I can tell this should work, but no matter what I do I get

Execution '' Cannot Be Found

Then I can not run any of the server reports at all, not just this one. Going to the reportserver I can run this report just fine. I just can't seem to get it so that this will render. Could someone please help me, I am about to go nuts!!!!

Thank you,

Josh

Ok, so I solved this problem by going from remote processing to local processing...I now have ran into another issue...I'll copy from my post over at the sql server 2005 forums where i have yet to receive a response....

Ok, I have been struggling with getting a report to run that I can pass parameters to for two days now, I have finally made progress on that front from going to local processing vs remote processing.

Now though I am about to pitch my computer underneath a truck if I don't get this solved shortly. I have two subreports as a part of this report. They aresupposedto be passed the id value as a parameter from the parent report. I found out that I still have to set data sources for these sub reports, so I attached the subreportprocessing event to the report viewer and attached the datasources that I created. My problem, I assume, is I don't understand how the dataset is supposed to be defined. I have tried three different ways. I built one dataset that has the relations to the two different tables that the sub reports use and built 3 distinct object data sources that reference the appropriate table adapters in the single dataset and I run the report.

Result I get every record in both tables for each record in the parent report

So next I tried creating three distinct datasets referencing the individual tables that the three reports would use (1 parent 2 child) and assign the datasources to the table adapters for the relevant reports and assigned them in the event.

Result I get every record in both tables for each record in the parent report

Finally I change the dataset to use a parameter to filter out the rows to only be the one for the relevant record in the report. I use the exact same name as the parameter that issupposedto be being passed from the parent report and assign accordingly in the subreportprocessing event

Result I get no error but I get no data either. I am assuming because it is not getting a parameter value.

I can find almost no information on this at all...I'm bashing my head on my desk yelling "WHY?"....this should not be this hard...please someone advise me in the proper direction. If you need any source samples please let me know....

|||

Does anyone have any ideas? I am running out of time to figure this out?

Thank you,

Josh

|||

Hello there:

In case you didn't play this drillthrough sample on:

http://www.gotreportviewer.com/

I am fighting for different issues with this reportviewer. It takes to long to figure out things that is supposed to be documented.

Good luck.

|||

I have spent a lot of time on that site, but it doesn't seem to have what I need.

Unfortunately I am not using drillthrough reports but just two sub reports...I implemented their sub reports exactly as they did except with sql instead of xml, but like I noted I return all results rather than the filtered results.

This truly should not be this hard....I have never wanted to go back to crystal reports until now....this is truly hurting my deadline...

Josh

|||

The reportviewer control is really meant to be used with local reports. Probably if you switched over to fully using the the report server or the reportviewer with local reports, you'll eliminate many of your difficulties.

|||

Hello again:

I look at the sample for the subreport and I found the way you assigned the parameter was different from the sample.

"Finally I change the dataset to use a parameter to filter out the rowsto only be the one for the relevant record in the report. I use theexact same name as the parameter that issupposedto be being passed from the parent report and assign accordingly in the subreportprocessing event"

Actually, you can assign the parameter through the property of the subreport: right click on your subreport> subreport Properties>Parameters: under this tab, you assign your parameter name and value. For example, mainID-- Field!mainID.Value.

I have read tons to find more about this control. I don't know whether this can fix your problem.

<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
Height="100%" Width="100%" AsyncRendering="False" SizeToReportContent="True">
<LocalReport ReportPath="YourMainReport.rdlc" OnSubreportProcessing="ReportViewer1_SubreportProcessing">
</LocalReport>
</rsweb:ReportViewer>

I think in OnSubreportProcessing you simply assign your subreport dataset to datasource. Another thing is to make sure the name of these datasets: yourDataset_yourDatatable. They have to be consistent with the definition in the source of your .rdlc files. You can check them to make sure.

I am close to get what I want to implement. I hope I can share with you with my findings.

|||

Limno,

You are right, I was doing it incorrectly. I solved my problem yesterday by a stroke of luck. You are right in the assumption that I was looking at the parameters incorrectly...I actually needed to pass all possible values to the sub report through the data source. I then needed to go in and make sure filtering was set up on the table that I was using to properly utilize the parameters passed to it. I wish this had been more clear in the documentation, or mentioned at all really, but it wasn't. Anyways, thank you for all of your help and if there is anything I can help with in your problem, please let me know!

Thanks,

Josh

Tuesday, March 27, 2012

embedded code to check parameter

Hi..
i have 2 parameters, start_date and end_date. is it possible to use
embedded code to prompt a message box if start_date is later than end
date ?
so far from what i've read, embedded code are called using the globally
defined 'Code' member. but in my case where i need to check the
parameters, how do i call the embedded code when user click the View
Report button ?
thanksss...The first thing that came to my mind is this:
1) Are you creating this report to run off a .NET webform? If you are,
you can make the check there and bring up the appropriate UI
2) The store procedure/or database call can also check the dates and
then either rerturn results, or one result saying "Error: Begin date is
after the end date" or if thta happens use default paramteres.
3) Also, you can edit report code to check the dates and either
hide/show (using the visible properties) , and display proper error
handling there.|||thanks Sorcerdon..
1) yes, the reports will run on .net webform. but where do i check?
2) the stored procedure will return a dataset.. so if i were to put a
one-line error message, the columns for table referencing the dataset
will be missing and hence caused an error when i preview report. or
have i done it incorrectly?
3) but the stored procedure will also be run if use the visibility
properties, no?
thanks again|||i manage to get the msg box out but without the caption.. i tried the
following code:
System.Windows.Forms.MessageBox.Show("Date Range From must be earlier
or the same as Date Range To","Error","OK","","")
but i received this error:
Overload resolution failed because no accessible 'Show' can be called
without a narrowing conversion:
i checked in msdn website and don't see what's wrong with my syntax...
anyhow, is there a way not to run the query for dataset since the dates
will not return result.
thanks..|||ops... i have another problem... the messagebox won't show when i view
it after deployment.

Monday, March 19, 2012

Email in SQL 2005 - Invalid parameter '@ansi_attachment'

Hello, I'm using xp_sendmail in SQL 2005 and received this error
"xp_sendmail: Invalid parameter '@.ansi_attachment'" ; is this
@.ansi_attachment no longer supported in 2005
Sample Below
Select @.SQLQuery = 'Declare @.rc int
EXEC @.rc = master.dbo.xp_sendmail
@.recipients = N'''+@.vTo+'''
,@.message = N'''+@.vMessage+'''
,@.query = N'''+@.vSQL+'''
,@.attachments =''Prices Expiring.txt''
,@.ansi_attachment=''TRUE''
,@.copy_recipients = N'''+@.vCC+'''
,@.subject = N'''+@.vSubject+'''
,@.attach_results = ''TRUE''
,@.width = 500I see this article but, since I do not see any mention of the parameter in
either 2000 or 2005 Books Online, I imagine this was only a temporary fix.
Is there any reason you would ever want to set the value to false? If not,
then my suggestion is to check the registry value (I can't imagine it would
default to false). Support will probably steer you towards database mail in
2005, as opposed to SQL Mail, anyway...
A
"Don" <Don@.discussions.microsoft.com> wrote in message
news:6362A1E7-524F-46C3-912D-ABBCCCA5A6DB@.microsoft.com...
> Hello, I'm using xp_sendmail in SQL 2005 and received this error
> "xp_sendmail: Invalid parameter '@.ansi_attachment'" ; is this
> @.ansi_attachment no longer supported in 2005
> Sample Below
> Select @.SQLQuery = 'Declare @.rc int
> EXEC @.rc = master.dbo.xp_sendmail
> @.recipients = N'''+@.vTo+'''
> ,@.message = N'''+@.vMessage+'''
> ,@.query = N'''+@.vSQL+'''
> ,@.attachments =''Prices Expiring.txt''
> ,@.ansi_attachment=''TRUE''
> ,@.copy_recipients = N'''+@.vCC+'''
> ,@.subject = N'''+@.vSubject+'''
> ,@.attach_results = ''TRUE''
> ,@.width = 500
>
>

Sunday, February 19, 2012

Either/Or/Any query returning erroneous(?) results

I have a query that accepts a parameter CustOwn, which can be 0/1/2
(represents =0/=1/=either 0 or 1)
In theory, by calling the query with CustOwn = 2, it should return the sum
of queries where CustOwn = 0 or CustOwn = 1, however I found I wasnt getting
these anticpated results.
I've created 3 versions of the query to hardcode the query for different
CustOwn values (see below). Apart from the 'and CustOwn = x' line, each
version is identical. Yet they return 17/16/8 records respectively - but the
first query should in theory return the sum of the last two queries. Can any
one suggest why this is the case?
[Apologies for the awful explanation!]
Code Snippet:
/* Both - CustOwn not specified */
Select FA.PartNo, FA.Stock, FOO.OnOrder, (Fa.Stock - FOO.OnOrder)as NumFree,
FA.WIP, (FA.Stock - FOO.OnOrder + FA.WIP) as FreeWIP
from FiltersAvailable FA
inner join (Select PartNo, Count(*) as OnOrder
from
(Select d.PartNo, o.Owned, o.Custorderno,
Case Left(o.custorderno,7)
When 'CustOwn' Then Cast(1 as bit)
Else Cast(0 as bit)
End as CustOwn
from orders o
inner join orderdetail d on d.orderid = o.orderid
where (d.StockMoveOut is null or d.StockMoveOut = '')) as FOO
Where (Owned = 0)
Group By PartNo) FOO on FOO.PartNo = FA.PartNo
order By FA.PartNo
/* CustOwn = 0 */
Select FA.PartNo, FA.Stock, FOO.OnOrder, (Fa.Stock - FOO.OnOrder)as NumFree,
FA.WIP, (FA.Stock - FOO.OnOrder + FA.WIP) as FreeWIP
from FiltersAvailable FA
inner join (Select PartNo, Count(*) as OnOrder
from
(Select d.PartNo, o.Owned, o.Custorderno,
Case Left(o.custorderno,7)
When 'CustOwn' Then Cast(1 as bit)
Else Cast(0 as bit)
End as CustOwn
from orders o
inner join orderdetail d on d.orderid = o.orderid
where (d.StockMoveOut is null or d.StockMoveOut = '')) as FOO
Where (Owned = 0)
and (CustOwn = 0) <===================
Group By PartNo) FOO on FOO.PartNo = FA.PartNo
order By FA.PartNo
/* CustOwn = 1 */
Select FA.PartNo, FA.Stock, FOO.OnOrder, (Fa.Stock - FOO.OnOrder)as NumFree,
FA.WIP, (FA.Stock - FOO.OnOrder + FA.WIP) as FreeWIP
from FiltersAvailable FA
inner join (Select PartNo, Count(*) as OnOrder
from
(Select d.PartNo, o.Owned, o.Custorderno,
Case Left(o.custorderno,7)
When 'CustOwn' Then Cast(1 as bit)
Else Cast(0 as bit)
End as CustOwn
from orders o
inner join orderdetail d on d.orderid = o.orderid
where (d.StockMoveOut is null or d.StockMoveOut = '')) as FOO
Where (Owned = 0)
and (CustOwn = 1) <==================
Group By PartNo) FOO on FOO.PartNo = FA.PartNo
order By FA.PartNo
Thanks
Chris
cjmnews04@.REMOVEMEyahoo.co.uk
[remove the obvious bits]>> Yet they return 17/16/8 records respectively - but the
first query should in theory return the sum of the last two queries. <<
it is sum(OnOrder), not number of rows, that for the
first query should in theory return the sum(OnOrder) of the last two
queries|||Well I'm not surprised nobody has answered by question... lol
I appear to have fixed the problem, but I'm still none the wiser!
I was missing some other criteria out of the inner loop. So when I added
this in, it 'fixed' the results such that I now get was was expected:
(CustOwn = Any) = (CustOwn = 1) + (CustOwn = 0)
I wouldnt have thought this would have made a difference but clearly it
has...
Chris|||Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. Sample data is also a good idea, along with clear
specifications. It is very hard to debug code when you do not let us
see it.
AND cust_own IN (SIGN(@.flag), SIGN(@.flag-2))
(0, -1)
(1, -1)
(1, 0)
Your code stinks. It is nested too deeply. You have BIT datatypes in
SQL! The availabilty of a filter is a status, not an entity.
StockMoveOut can be empty or NULL and they are given the same meaning.
I am going to guess that Ordes had no infomation that should not have
been in Order Details for this query.