S
scparker
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.EventArgs)
Handles ConfirmEdit.Click
'*** Declare
Dim RequestedDate As Nullable(Of Date)
'*** Populate
RequestedDate=ERequestedDate.Text
Result1 = DataTable.Update(Id, RequestedDate, ConfirmedDate)
End Sub
--------------------------------------
The DataTable.Update 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=True
DefaultValue=<DBNull>
---------------------------------------------
The Stored Procedure allows for Nulls:
---------------------------------------------
CREATE PROCEDURE [dbo].[Update]
(@Id int,
@RequestedDate datetime = null,
@ConfirmedDate datetime = null)
AS
BEGIN
~~~~~~~
END
GO
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.EventArgs)
Handles ConfirmEdit.Click
'*** Declare
Dim RequestedDate As Nullable(Of Date)
'*** Populate
RequestedDate=ERequestedDate.Text
Result1 = DataTable.Update(Id, RequestedDate, ConfirmedDate)
End Sub
--------------------------------------
The DataTable.Update 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=True
DefaultValue=<DBNull>
---------------------------------------------
The Stored Procedure allows for Nulls:
---------------------------------------------
CREATE PROCEDURE [dbo].[Update]
(@Id int,
@RequestedDate datetime = null,
@ConfirmedDate datetime = null)
AS
BEGIN
~~~~~~~
END
GO