如果db查询有值,则Chech [英] Chech if db query has value
本文介绍了如果db查询有值,则Chech的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试检查数据库查询是否具有值,如果它没有问题,但是它没有说明异常详细信息:Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:无法对空引用执行运行时绑定。我正在使用这样的代码
I'm trying to check if db query has value if it has it's fine, but whnen don't it says Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference. I'm using code like this
var spravy= db.QuerySingle(" SELECT * FROM Messages WHERE ToUserID=@0 AND State='2'",WebSecurity.CurrentUserId);
if(spravy.ExecuteScalar()!=null)
{
spravy="(1)";
}
推荐答案
If (db.querysingle(blah blah ) !- null)
{
spravy = blah;
}
这篇关于如果db查询有值,则Chech的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文