I have yet to find a satisfactory solution to this problem. It involves
VB.NET 2.0 and datetime issues.
I have a form that asks for a Date to be submitted in dd/mm/yyyy
format. When this is submitted it then is then dealt with as follows:
------------------------------------
Public Sub Update(ByVal sender As Object, ByVal e As System.EventArg s)
Handles ConfirmEdit.Cli ck
'*** Declare
Dim RequestedDate As Nullable(Of Date)
'*** Populate
RequestedDate=E RequestedDate.T ext
Result1 = DataTable.Updat e(Id, RequestedDate, ConfirmedDate)
End Sub
--------------------------------------
The DataTable.Updat e represents the datatable used and the method is
calling a stored procedure that updates a particular record based on an
id given to it.
Now, the above code is a simplification - but the principle si the
same. The ConfirmedDate may have nothing in it - and causes the
"Nullable object must have a value. " error.
The DataTable allows for DBNull.
---------------------------------------------
DataType=System .DateTime
AllowDBNull=Tru e
DefaultValue=<D BNull>
---------------------------------------------
The Stored Procedure allows for Nulls:
---------------------------------------------
CREATE PROCEDURE [dbo].[Update]
(@Id int,
@RequestedDate datetime = null,
@ConfirmedDate datetime = null)
AS
BEGIN
~~~~~~~
END
GO
---------------------------------------------
The Database allows For Nulls:
---------------------------------------------
DataType=dateti me (8)
Null=True
DefaultValue=Nu ll
---------------------------------------------
But yet the update will not work when the ConfirmedDate value has
nothing in it. Does anybody have any ideas how to get round this?
VB.NET 2.0 and datetime issues.
I have a form that asks for a Date to be submitted in dd/mm/yyyy
format. When this is submitted it then is then dealt with as follows:
------------------------------------
Public Sub Update(ByVal sender As Object, ByVal e As System.EventArg s)
Handles ConfirmEdit.Cli ck
'*** Declare
Dim RequestedDate As Nullable(Of Date)
'*** Populate
RequestedDate=E RequestedDate.T ext
Result1 = DataTable.Updat e(Id, RequestedDate, ConfirmedDate)
End Sub
--------------------------------------
The DataTable.Updat e represents the datatable used and the method is
calling a stored procedure that updates a particular record based on an
id given to it.
Now, the above code is a simplification - but the principle si the
same. The ConfirmedDate may have nothing in it - and causes the
"Nullable object must have a value. " error.
The DataTable allows for DBNull.
---------------------------------------------
DataType=System .DateTime
AllowDBNull=Tru e
DefaultValue=<D BNull>
---------------------------------------------
The Stored Procedure allows for Nulls:
---------------------------------------------
CREATE PROCEDURE [dbo].[Update]
(@Id int,
@RequestedDate datetime = null,
@ConfirmedDate datetime = null)
AS
BEGIN
~~~~~~~
END
GO
---------------------------------------------
The Database allows For Nulls:
---------------------------------------------
DataType=dateti me (8)
Null=True
DefaultValue=Nu ll
---------------------------------------------
But yet the update will not work when the ConfirmedDate value has
nothing in it. Does anybody have any ideas how to get round this?
Comment