Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Dear Coders,

I am having trouble assigning a date datatype value to null. If i assign like

VB
Dim MyDate as Date

MyDate = DbNull.value


Its showing error like cannot convert the value. Please Help.
Posted
Updated 21-Nov-12 21:09pm
v2
Comments
Sergey Alexandrovich Kryukov 22-Nov-12 2:49am    
Of course you cannot. This is not a nullable type; and DbNull is a special type used to conduct a notion of null in relational databases, which is not the same thing as CLI null. This is a double incompatibility.

Better explain what exactly do you want to achieve. DbNull makes no sense if you don't use ADO.NET. Where do you use it?

--SA
armarzook 22-Nov-12 3:09am    
Sorry. not data datatype.. Its Date Datatype.

You can't assign DBNull.Value to anything in particular - it is a value that is passed between .NET and SQL to indicate a null value in a database table, not a value you can generally use in your application. Try Nothing instead. (But that probably won't do what you want either :laugh:)
 
Share this answer
 
Comments
armarzook 22-Nov-12 3:19am    
Read the question now please...
OriginalGriff 22-Nov-12 3:23am    
Still not changed - you still can't assign DBNull.Value to a Date datatype - it isn't a value it can accept.
Is this you looking for.. - Assigning null value to datetime object[^]

armarzook wrote:
MyDate = DbNull.value

here DbNull does not represent anything if you are not using ADO.Net..
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900