Click to See Complete Forum and Search --> : Passing null date to a table adapter


CoderGuru
03-28-2008, 02:57 AM
Hello,

I have a table adapter that calls for a set of variables. Three of which are smalldatetime variables. My stored procedure that it passes to looks like this:

PROCEDURE [dbo].[Timesheet_Select_All_Paged]
@startRowIndex int,
@maximumRows int,
@project INT,
@company INT,
@user INT,
@service INT,
@date SMALLDATETIME = null,
@rangeStart SMALLDATETIME = null,
@rangeStop SMALLDATETIME = null
AS
BEGIN

As you can see, even my default variables for the last three are null. I do this because it allows me to pass null if I want no range.

Problem is, when I pass nothing for these variables to my dataset I get an SQLDataTime overflow error as pasted below. Can anyone please tell me how I can pass a null variable to this table adapter? I am using VB.net BTW, reason I used Nothing.


SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
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.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

CoderGuru
03-28-2008, 03:17 AM
After attempting dbnull.value, convert.dbnull I ended up using the default value of new datetime(1900, 1, 1) to equal my null. This however is a hack and I like my coding to be correct so if anyone knows a solution to passing a null datetime value to a table adapter please let me know. Thanks in advance.

chazzy
03-28-2008, 07:03 AM
Can you post the actual code you're using to apply the parameters? What happens if you don't apply a value at all for these datetimes?