public static bool CheckIfUserISbanned(Guid guid)
{
StringBuilder sb = new StringBuilder();
sb.Append("SELECT Banned");
sb.Append(" FROM dbo.Users");
sb.Append(" WHERE [email protected]");
object o;
bool isBanned = false;
string myConnectionString = AllQuestionsPresented.connectionString;
using (SqlConnection conn = new SqlConnection(AllQuestionsPresented.connectionString))
{
SqlCommand cmd = new SqlCommand(sb.ToString(), conn);
conn.Open();
cmd.Parameters.Add("@UserID", SqlDbType.UniqueIdentifier).Value = guid;
o = cmd.ExecuteScalar();
}
isBanned = o == null ? false : true;//Problem here
return isBanned;
}
問題は、オブジェクトが常にnullでない値を受け取ることです。しかし、禁止されたフィールドのUsersテーブルでは、そのタイプを "Allow Nulls"に設定しました...ヌルがあることがわかりましたが、ヌルが検索されませんでした。他のものは.. "isBanned"真実..いつも..なぜそれが起こっているのか、そしてその物体がいつ真実であるかを私は知ることができます。"bit"データ型に関する質問
良いです。グラハム!!!それは働いた – WithFlyingColors