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

Monday, March 26, 2012

No Date passed

I want to update a record that has a datetime field in it. But what if there is no parameter given for that field, i.e. what is the correct type/value to pass as parameter?

Example: A DOB field for a user profile, but the user doesn't enter his birthday

This is some example code that I use to update:


Private Sub UpdateDOB(ByVal dob As Date)

Dim parameters As SqlParameter() = { _
New SqlParameter("@.Birthday", SqlDbType.DateTime, 8)}

parameters(0).Value = dob

'Run Stored Procedure


This gives me the exception "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM" when I don't pass a valid date. I tried passingNothing but same error (in this case it convert dob to "#12:00:00 AM#")

The only thing I can think of is to use Date.MaxValue and then check in application logic, but there must be a better way!use dbnull.value

hth|||ndinakar, I tried this:

User.DOB = System.DBNull.Value

but then I get an error, DBNull.Value cannot be converted to Type Date
how should i assign DBNull.Value ?|||Instead of passing DOB as date pass it as string


Private Sub UpdateDOB(ByVal strDOB As string)
...
cmd.Parameters.Add(New SqlParameter("@.Birthday", SqlDbType.DateTime))

If (strDOB= "") Then
cmd.Parameters("@.Date").Value = sqldatenull
'cmd.Parameters("@.Date").Value = DBNull.Value
Else
cmd.Parameters("@.Date").Value = DateTime.Parse(strDOB)
End If

HTH|||or this :


myCommand.Parameters.Add(New SqlParameter("@.cusbday",SqlDbType.datetime))
If len(trim(bday.Text)) = 0 Then
myCommand.Parameters("@.cusbday").Value = SqlDateTime.null
Else
myCommand.Parameters("@.cusbday").Value = server.htmlencode(DateTime.Parse(bday.Text))
End If

you need to import system.data.sqldypes namespace.

hth|||Thank you

SqlDateTime.Null worked fine as parameter.sql

Wednesday, March 21, 2012

No available values in Report Builder parameter

In a Report builder report I have runtime prompt filter on a field.
But I am not able to see the available values in the dropdown for this field.
My filter is on a "New Field" with the formula :
IF(LENGTH(FieldName)>0,FieldName,("Blank"))

However if my filter is on the FieldName directly and not on the New Field with the above formula I do get the available values.
Is there any way I can get the available values in a dropdown for the New Field?

In Model Designer, add the "New Field" formula as a new attribute to the entity. Then set ValueSelection of the attribute to be dropdown.|||

True any field which is present in the Model can be shown in the dropdown.

I was exploring if a new formula field that is not actually present in the model, might also have 'Available values'.Thanks for your response.

sql

No available values in Report Builder parameter

In a Report builder report I have runtime prompt filter on a field.
But I am not able to see the available values in the dropdown for this field.
My filter is on a "New Field" with the formula :
IF(LENGTH(FieldName)>0,FieldName,("Blank"))

However if my filter is on the FieldName directly and not on the New Field with the above formula I do get the available values.
Is there any way I can get the available values in a dropdown for the New Field?

In Model Designer, add the "New Field" formula as a new attribute to the entity. Then set ValueSelection of the attribute to be dropdown.|||

True any field which is present in the Model can be shown in the dropdown.

I was exploring if a new formula field that is not actually present in the model, might also have 'Available values'.Thanks for your response.

Friday, March 9, 2012

next 30 days or all values

Hi,
I have a dataset and I need to be able to filter that data based on
Completion Date.
I have created a user parameter is SSRS with the following values:
0 = All Dates
1 = Next 30 days
I am trying to filter my dataset but I don't know how to filter this
based on my user parameter.
Help!
JasonI figured it out
if the user selects "All" then Parameter!Completion.Value = 0
if the user selects "Next 30 Days" then Parameter!Completion.Value = 1
so my filter looks like:
=iif (Parameters!Completion.Value=1, date.Today.AddDays(30),
date.MaxValue)

Saturday, February 25, 2012

newbie: value expression... uses an aggregate expression w/o a sco

simply added a report parameter for a working report (which went fine and w/o
issue..)
next thing, went to build the report in VS.NET and got 100 Build Errors
telling me that every TextBox on my summary page has the error:
'The value expression for the textbox '...' uses an aggregate expression
with a scope...'
Newbie (I know), but what on earth did I do that would have screwed up
everything like this?
( Scope for what? The report and parameters already have everything they
need as far as data goes.)
Rob(this is a frickin nightmare...)
So it looks like every time I try to add a new report parameter, after
deleting the original (simply the report parameter became a different report
item), about half of the textboxes which are sums and counts threw this error
(which is nutty as heck, since about 2/3, which have the same thing are OK).
Is this some kind of bug? (Deleted all Report Parameters and I can compile
w/o errors.)
What's going on with this and what does it take to 'set the scope'.
Rob
"RobKaratzas" wrote:
> simply added a report parameter for a working report (which went fine and w/o
> issue..)
> next thing, went to build the report in VS.NET and got 100 Build Errors
> telling me that every TextBox on my summary page has the error:
> 'The value expression for the textbox '...' uses an aggregate expression
> with a scope...'
> Newbie (I know), but what on earth did I do that would have screwed up
> everything like this?
> ( Scope for what? The report and parameters already have everything they
> need as far as data goes.)
> Rob
>