How to parse Nullable from a SqlDataReader

后端 未结 6 750
情歌与酒
情歌与酒 2021-01-17 17:37

The DateTime.TryParse method takes a DateTime as an argument, not a DateTime? ?

Right now I have the following code:

if(!DateTime.TryParse(reader[\"P         


        
6条回答
  •  广开言路
    2021-01-17 17:57

    How about this instead:

    int x = reader.GetOrdinal("Placed");
    
    if(!reader.IsDBNull(x))
        _placed = reader.GetDateTime(x);
    

提交回复
热议问题