UPDATE:この文はあなたがIS NULLとの間のスペースを必要とするの場合とNullのSQL文
public void CheckReputationIfNull()
{
StringBuilder sb = new StringBuilder();
sb.Append("DECLARE @isReputationNull int");
sb.Append(" SET @isReputationNull=(SELECT Reputation");
sb.Append(" FROM Users u");
sb.Append(" INNER JOIN Comments c ON c.UsersID = u.UsersID");
sb.Append(" WHERE c.CommentsID = @CommentsID)");
sb.Append(" BEGIN IF (@isReputationNull IS NULL)");
sb.Append("UPDATE u ");
sb.Append(" SET Reputation = 0");
sb.Append(" FROM Users u");
sb.Append(" END");
using (SqlConnection conn = new SqlConnection(AllQuestionsPresented.connectionString))
{
SqlCommand cmd = new SqlCommand(sb.ToString(), conn);
cmd.Parameters.Add("@CommentsID", SqlDbType.Int).Value = commentID;
conn.Open();
cmd.ExecuteNonQuery();
}
}
いいえ、それは働いています。助けてくれてありがとう – WithFlyingColors