views:

2959

answers:

1

Howdy,

I have a DataSet with a DataTable that fills a single row through a TableAdapter.

The TableAdapter is correctly filling a DataRow in the DataTable.

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 in the SQL 2005 database table 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.

Any suggestion would be very helpful.

Thank you,
Keith

EDIT:

Ok, so I had a problem where Visual Studio was 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.
Keith

+1  A: 

The code above works, make sure you set your debugger to compile for Debug, NOT Release.

Keith

Keith Sirmons