Reputation: 429
I have one page to view all Universities,and I want this page to view filtered data as per city, I added to SQL statement:
WHERE (Cit_Id = @Unv_CitId OR @Unv_CitId IS NULL)
and set DefaultValue of @Unv_CitId parameter to NULL, but I got error,
How can I solve this issue?
Upvotes: 1
Views: 344
Reputation: 66
delclare @Unv_CitId as null while declaring parameter in procedure as shown below
@Unv_CitId int NULL
so the varibale will accept null value as well.
Upvotes: 0
Reputation: 429
Yes now it is ok, I set SqlDataSource's CancelSelectOnNullParameter property to False, and delete the defaultValue of the parameter
Upvotes: 0
Reputation: 14938
I'm not 100% sure of your intention, but what about something like this:
WHERE (Cit_Id = @Unv_CitId OR Cit_Id IS NULL)
Your original query looks a little odd with @Unv_CitId IS NULL
in there: this clause isn't checking against a field, merely against the value being passed in.
Upvotes: 0
Reputation: 1888
you can try this
where (Cit_Id = isdbnull(@Unv_CitId)?null:@unv_citId
Upvotes: 0