如果数据库中不存在 UserId,我想显示“未找到配置文件”消息。我该如何实现它。下面的代码不起作用。
UserId = Request.QueryString["UserId"];
var db = Database.Open("mystring");
var selectCommand = "SELECT * FROM UserProfile WHERE UserId = @0";
var row = db.QuerySingle(selectCommand, UserId);
if (row != null)
{
Email = row.Email;
fullname = row.fullname;
about = row.about;
}else{
ModelState.AddFormError("No Profile Found.");
}