[英]Checking null value for integer from DataBase
I have a student table that references a parent table, as a FK. 我有一个学生表,它引用一个父表作为FK。 But a student can be older than 18, in which case he's responsable for himself and the
parent_id
is set to null. 但是学生可以年满18岁,在这种情况下,他应该对自己负责,并且
parent_id
设置为null。 I have to check if the id is null, but: 我必须检查id是否为null,但是:
if (dtreader_resp.Read())
{
if(dtreader_resp.GetInt16("resp_id") != null)
{
resp.Resp_id = dtreader_resp.GetInt16("resp_id");
}
}
Always returns true. 始终返回true。 Is there a way to check if that field is null?
有没有办法检查该字段是否为空?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.