I have setup a report. I am calling the report from a page which passes parameters in a query string to the report.
The parameters are to be used in a stored procedure which the "Object Data Source" of the report refers to.
The stored procedure queries the data ina table and this data should be displayed in the report.
What actually happens is that the report appears but it has only the first record in the table but this is not the record
specified by the parameters passed to the stored procedure. It look as if the report is attaching to the correct table but
the query is not being executed properly.
Anyone any ideas how to fix this?
macca
Does ur storeprocedure return the right data when u run in SSMS or in the Data layout of ur report?
|||Thanks for the reply Karenros but how do I test what you are suggesting.
Thanks,
macca
|||Go to sql server ManagementStudio and then go to the database u wanna access and then click on new query.. in the new query window type in ur sproc name and give the parameters for ur sproc and u should see the results in the same window...
Or u can go to ur report in VS2005 and then click on the data part of ur report and u will see the name of the dataset and the sproc name.. next to the sproc click the exceute button and it will prompt u for parameters and after u enter them they should display the results...
Hope this helps.
Regards
Karen
|||Thanks for that Karen that works.I am getting another problem though. I am calling the report via a Response.redirect but am getting an error with the dates formats. The error message is as follows:"An error has occurred during report processing.· String was not recognized as a valid DateTime." I am calling the report and the url looks like this:· · "/PaymentReport.aspx?Section=107&DateFrom=02/10/2007&DateTo=19/10/2007". When I try the method you suggested above I must put in the DateFrom as 10/2/2007 and DateTo as 10/19/2007. The report is obviously not getting the dates in the query string in the correct format and therefore the error.How are u storing ur date time in ur database. looks like the format you are using is dd/mm/yyyy... and by any chance is the date in ur database stored as mm/dd/yyyy?
Regards
Karen
|||Macca,
while u are giving ur date Parameter try putting it in Single quote... take a look at this code.
Declare @.reqDeldatedatetimeSet @.reqDeldate ='1/31/2007'Select OrderId, OrderDate, PlanId, RequiredDeliveryDateFrom [Order]Where RequiredDeliveryDate = @.reqDeldate
If i just @.reqDeldate as 1/31/2007 instead of '1/31/2007' nothing shows up.
So try giving it quotes..
Regards
Karen
|||
Thanks Karen that worked.
I now have another problem. The report is not bringing back the correct results from the query. It appears to just bring back one record multiple times.
But if I run the query it brings back the correct results.
I don't know why it is doing this.
Any ideas?
macca
|||can u pls post ur store procedure code? and have u tried refreshing the data in VS studio.. cause sometimes i have seen display the old data... and after i refresh it works fine... and try deploying it to the report server to see if it gives the correct results.
Hope this helps.
Regards
Karen
|||Here is my Stored procedure:
CREATE PROCEDURE sproc_PaymentReports
(
@.DateFrom Datetime,
@.DateTo Datetime,
@.Status Int,
@.Section Int
)
AS
BEGIN
SELECT cheq_id, cheq_daterec, cheq_pername, cheq_amt
FROM RecCheqs
WHERE cheq_DateRec >= coalesce(nullif(@.DateFrom, ' '),cheq_DateRec) AND cheq_DateRec <= coalesce(nullif(@.DateTo, ' '),cheq_DateRec)
AND cheq_dept = coalesce(nullif(@.Section , ' '),cheq_dept)
AND cheq_added = coalesce(nullif(@.Status , ' '),cheq_added)
END
GO
How do you deploy to the report server?
macca
Do u have a report server setup? if yes
then in VS go to Project and then click on properties and in the window that comes up Give a
Name for the TargetReportFolder. and in the TargetServerURL ... give http:/Either localhost or an ipaddress/ReportServer
and click ok ... for the first time the overwriteDatasources to false...but sometimes i would have to make changes to the report to the dataset so i just set it to true.
Once u set ur project properties... Go to Build -- Deploy Project name and it should prompt for a user name and password if required...
and to run ur report from the report server... go to the address that u specified in the TargetReportServerURL and then navigate to the folder name and click on the main report that runs it... and then its like .... runing it from Visual studio
Hope this helps...
Regards
Karen
|||I don't have a report server setup so can't do any of that. This is not doing it for me at all.
In .net 1.1 I used to create reports using a Repeater and I would run the stored procedure and it would "Bind" the data to the repeater and it would work fine.
I have tried this with the ReportViewer using the following code but cannot get it to Bind:
Dim oDSAs DataSetDim oChequeAsNew Cheque
Try
oDS =New DataSetoDS = oCheque.GPAssignedReport(dateFrom, dateTo, Section, Status)
If oDS.Tables(0).Rows.Count > 0Then
rptVwPayment.DataBind()
rptVwPayment.Visible =True
This code works for the repeaters in 1.1 but cannot get it to bind to report.
Any ideas, as I am ready to abandon Reports as a pack of rubbish.
macca
|||i have used the report viewer control... but only done it using remote processing cause all my reports are located in the report server.
|||Karen,
Thanks for all your help I got that resolved.
macca
No comments:
Post a Comment