Reputation: 9660
I have two textboxes on the screen. They are used for startdate and enddate. If the user does not enter anything in the textboxes I pass nothing (VB.NET) to the webservice. When the webservice receive it on the other end it shows the value "#12:00:00 AM" which I think is the default for the datetime field. Anyway, now I do not want to pass this value to Stored procedure since it will not work. How can I check before sending values to sproc that the value is not the default datetime.
Upvotes: 2
Views: 3586
Reputation: 2595
Instead of DateTime use Nullable of DateTime. Then you can pass a null (or nothing) value to the web service and you use Date.HasValue to check if a value was entered/passed.
Upvotes: 0
Reputation: 2457
I can think of two options here.
Since you already know that you're receiving "#12:00:00AM" when the field is not filled in, check if the value you receive is "#12:00:00AM".
Prior to passing the value to your stored procedure, create a new DateTime object. Compare the value you're receiving against the value in the new DateTime object.
Upvotes: 0
Reputation: 460138
If you don't want to pass it to the WebService, why do you pass it anyway?
To see if a Date is not the "default-date":
If Not Date.MinValue = MyDate
Upvotes: 2