. Net 1.1 does not support SQL server when the datetime field is null
The SQL server datetime field supported by. net 2.0 is null.
If datetime is not supported,
The SQL server database tutorial generally selects a specific date to indicate a null value. By default, it is
In the asp tutorial, how can I process fields with datetime null?
// In this example, user is an object class object.
If (user. lastlogindate. hasvalue)
{
Lblinfo. text = user. lastlogindate. value. tostring ("yyyy-mm-dd ");
}
Else
{
Lblinfo. text = "never logged on! ";
}
If the datetime type field in SQL server is null, it cannot be directly converted to a datetime type variable after it is obtained in c. Of course, it cannot be determined whether it is equal to null. It should be determined whether it is equal to dbnull. value. When the object class is used, you can set the specified attribute to be allowed to be null, and similar to public datetime? Lastlogindate method definition. In this way, the lastlogindate attribute is assigned only when the date field in the result set is not equal to dbnull. value. When using datetime? Type variable, use its hasvalue attribute for judgment and processing