Solved

# Easy Boolean algebra problem

Posted on 2007-04-11

I'm having a very dumb issue with my Boolean algebra and I can't find the error. I'm hoping someone can help me. Here's my code -- it's largely trace output for debugging:

(Just for context, it's in the middle of a for loop. The row object is of type DataRow.)

Trace.Write("Current row: " + row["user_id"] + ", " + row["file_id"]);

Trace.Write("row[\"can_upload\", DataRowVersion.Original] = " +

(row.HasVersion(DataRowVersion.Original) ? row["can_upload", DataRowVersion.Original] : "DataRowVersion.Original does not exist."));

Trace.Write("row[\"can_download\", DataRowVersion.Original] = " +

(row.HasVersion(DataRowVersion.Original ) ? row["can_download", DataRowVersion.Original] : "DataRowVersion.Original does not exist."));

Trace.Write("row[\"can_upload\", DataRowVersion.Current ] = " +

(row.HasVersion(DataRowVersion.Current) ? row["can_upload", DataRowVersion.Current] : " DataRowVersion.Current does not exist."));

Trace.Write("row[\"can_download\", DataRowVersion.Current] = " +

(row.HasVersion(DataRowVersion.Current) ? row["can_download", DataRowVersion.Current] : "DataRowVersion.Current does not exist."));

if(row.HasVersion(DataRowVersion.Original)) {

Trace.Write("Upload, original equals current? " + (row["can_upload", DataRowVersion.Original] == row["can_upload", DataRowVersion.Current]).ToString());

Trace.Write("Download, original equals current? " + (row["can_download", DataRowVersion.Original] == row["can_download", DataRowVersion.Current]).ToString());

}

if( row.HasVersion(DataRowVersion.Original) &&

((row["can_upload", DataRowVersion.Original] == row["can_upload", DataRowVersion.Current]) &&

(row["can_download", DataRowVersion.Original] == row["can_download", DataRowVersion.Current])) )

{

Trace.Write("No change for user: " + (int)row["user_id"]);

continue;

}

Trace.Write("Permissions changed for user: " + (int)row["user_id"]);

Here's the output:

Current row: 1437, 2078

row["can_upload", DataRowVersion.Original] = True

row["can_download", DataRowVersion.Original ] = True

row["can_upload", DataRowVersion.Current] = True

row["can_download", DataRowVersion.Current] = True

Upload, original equals current? False

Download, original equals current? False

Permissions changed for user: 1437

So, row["can_upload", DataRowVersion.Original] is true, row["can_upload", DataRowVersion.Current] is true, but they don't have the same boolean value? Can someone help me out here please?