I have a DataSet
with a DataTable
that correctly fills a single DataRow
through a TableAdapter
.
I am able to pull data from the DataRow with code like this:
dataFileID = (int)this.dataFileDataRow["DataFileID"];
dataFileName = (string)this.dataFileDataRow["DataFileName"];
dataFileDate = (DateTime)this.dataFileDataRow["DataFileDate"];
I have another column called DataFile of type varbinary(max)
.
When I try to pull that column's data from the same DataRow
as above I get nothing.
byte[] fileFromDatabase = (byte[])this.dataFileDataRow["DataFile"];
If I put a break point at this location, I can look into the dataFileDataRow, look into the ItemArray property and see that the binary data is sitting at position 5 in the ItemArray.
I have tried access the ItemArray directly using its index but the byte array is not being copied to the fileFromDatabase variable.
I have also noticed that adding fileFromDatabase to my watch produces this error:
"The name 'fileFromDatabase' does not exist in the current context"
The execution is still in the same block as the definition of fileFromDatabase so I do not understand how it would be out of context.
I had Visual Studio's configuration set to Release instead of Debug. This was causing me to not see the real time debugging information I was looking for when trying to examine fileFromDatabase. After switching from Release to Debug, I am able to see the variable in the watch now and can verify that the code above is working correctly.