Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Reporting Services: Problem passing dates to a sp

Author  Topic 

el_boufador
Starting Member

4 Posts

Posted - 2004-08-16 : 04:27:52
Hi,
I'm new to reporting services. I want to create a report based on values a user chooses from two asp.net web form calendar controls.
I'm passing the two dates to a stored procedure which produces the results on which the report is based.

The report works fine in the report designer preview (and in report manager) - I type in the dates and the report comes back great. It also works fine if I code some test date parameters into the asp.net web form (e.g. parameters(0).Value = "04/04/2003" )

However, when I try to get the values from the web form calendar controls it all goes wrong. When I run the report from my asp.net web form I get an error:

"Default value or value provided for the report parameter 'StartDate' is not a valid value. --> Default value or value provided for the report parameter 'StartDate' is not a valid value. --> Default value or value provided for the report parameter 'StartDate' is not a valid value.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Services.Protocols.SoapException: Default value or value provided for the report parameter 'StartDate' is not a valid value. --> Default value or value provided for the report parameter 'StartDate' is not a valid value. --> Default value or value provided for the report parameter 'StartDate' is not a valid value."


parameter values are type string, so I am doing Format$(calStart.SelectedDate, "d/M/yyyy"). I've tried all sorts of styles for the dates, (dd/MM/yyyy, yyyy-mm-dd etc.) but nothing seems to work.

Any ideas what I could be doing wrong? Thanks for any ideas.

This is what my code looks like.
>>>The user chooses a date from a calendar server control, and this is formatted as string:

Private Sub calStart_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calStart.SelectionChanged

strStart = Format$(calStart.SelectedDate, "d/M/yyyy")

End Sub

>>>Then I create the parameters and render the report

Private Sub cmdRenderHTML_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRenderHTML.Click

Dim rs As New ReportingService

rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.Url = "http://JHPN76/ReportServer/ReportService.asmx"

Dim results As [Byte]()


Dim parameters(1) As ParameterValue
parameters(0) = New ParameterValue
parameters(0).Name = "StartDate"
parameters(0).Value = strStart
parameters(1) = New ParameterValue
parameters(1).Name = "EndDate"
parameters(1).Value = strEnd


results = rs.Render("/HAIGHN/Comp2", "HTML4.0", Nothing, "<DeviceInfo><HTMLFragment>True</HTMLFragment></DeviceInfo>", parameters, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
Response.ClearContent()
Response.BinaryWrite(results)

Response.Flush()
Response.Close()

End Sub


>>> Note strEnd is given a value in the same way as strStart (see above).

>>>When I run the app, I get the following error:


>>> the parameters are declared as

@StartDate datetime,
@EndDate datetime

in my sp.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-08-16 : 05:11:45
could this be it?
Dim parameters(1) As ParameterValue -> Dim parameters(2) As ParameterValue



Go with the flow & have fun! Else fight the flow :)
Go to Top of Page

el_boufador
Starting Member

4 Posts

Posted - 2004-08-16 : 05:29:54
Thanks for your reply spirit1.

If I dim as (2) get the following error:

The value of parameter 'Parameters' is not valid. Check the documentation for information about valid values. --> The value of parameter 'Parameters' is not valid. Check the documentation for information about valid values.

I guess this must be because the sp is now getting an (unnamed) parameter it wasn't expecting...
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-08-16 : 05:50:02
maybe that's not it then :))
i see that you add parameteres like this:

parameters(0).Name = "StartDate"

if parameteres in your stored procedure are named @StartDate like they supposed to, you should do:

parameters(0).Name = "@StartDate"




Go with the flow & have fun! Else fight the flow :)
Go to Top of Page

el_boufador
Starting Member

4 Posts

Posted - 2004-08-16 : 06:28:34
Yes - This is one of the weird things I've found about reporting services - if you name the parameters with the @, you get the following:

An attempt was made to set a report parameter '@StartDate' that is not defined in this report. --> An attempt was made to set a report parameter '@StartDate' that is not defined in this report. --> An attempt was made to set a report parameter '@StartDate' that is not defined in this report.

you leave the '@' out and it runs ok (well, with the exception of date parameters!)

very odd!

Thanks again
Go to Top of Page

el_boufador
Starting Member

4 Posts

Posted - 2004-08-16 : 09:25:05
Sussed it!
I declared the parameters as varchar on the stored procedure and did a convert to datetime.

I'm still not quite sure what was wrong in the first place though, seeing as

parameter(0).value = "01/01/2004"

works OK.

Thanks for your help
Go to Top of Page

san.vb
Starting Member

4 Posts

Posted - 2007-03-31 : 03:21:38

Default value or value provided for the report parameter 'intSecurityID' is not a valid value. ---> Microsoft.ReportingServices.Diagnostics.Utilities.RSException: Default value or value provided for the report parameter 'intSecurityID' is not a valid value. --->

I am getting the above error when 'intSecurityID' parameter contains the value of 150 or greater than 150.

If the 'intSecurityID' value is lesser than 150 then reports working fine, not displaying any error... please help!!
Regards,
Sanjiv
Go to Top of Page

san.vb
Starting Member

4 Posts

Posted - 2007-04-02 : 02:24:06
quote:
Originally posted by el_boufador
Hi,
I am getting the same error with integer field type. I have declared a paramater as "intSecurityId" in the rpeort . and from reporting service i am passing a parmeter value of 1000. i am getting error as "invalid parameter value"
I have modify the type of intsecurityId as string in the report but no luck.. pls help.

Regards,
Sanjiv

Yes - This is one of the weird things I've found about reporting services - if you name the parameters with the @, you get the following:

An attempt was made to set a report parameter '@StartDate' that is not defined in this report. --> An attempt was made to set a report parameter '@StartDate' that is not defined in this report. --> An attempt was made to set a report parameter '@StartDate' that is not defined in this report.

you leave the '@' out and it runs ok (well, with the exception of date parameters!)

very odd!

Thanks again

Go to Top of Page
   

- Advertisement -