2
ブログエントリのコメントリストを含むMySqlDataAdapterで埋められたDataTableを使用しようとしています。何らかの理由で、フィールド "anonymous"が "1"に設定されている場合、usernameフィールドは空であり、指定された文字列で置き換えなければなりません。私のDataTableは常に "true/false"を返すが、文字列は返さないのはなぜですか?
問題は、フィールドの値を取得しようとするたびに、「true」または「false」のいずれかになります。私のコードは次のようになります。
DataTable modifiedComments = new DataTable();
// The function GetCommentsById() returns a MySqlDataAdapter with the result of the query
MySqlDataAdapter commentsContainer = Wb.Entry.GetCommentsById(imageId);
commentsContainer.Fill(modifiedComments);
commentsContainer.Dispose();
foreach (DataRow row in modifiedComments.Rows)
{
string status;
// This never returns true, so we always get into the else
if (row["anonymous"] == "1")
{
status = "You are anonymous";
}
else
{
status = "You are not anonymous";
}
}
viewImageCommentsRepeater.DataSource = modifiedComments;
viewImageCommentsRepeater.DataBind();