Tales of a self taught coder

Visualizers in Visual Studio

I had a question from another member of a list I follow the other day regarding the ability to "Visualize" a dataset during a debugging session.  Since he asked the question and it was one of those things that I just take for granted, I thought I would write a quick post to hopefully help anyone out who has never seen the feature before.

The first thing I did was do a bit of research on MSDN to make sure they didn't clearly document it.  MSDN does a pretty good job of explaining it:

MSDN Documentation 

However, as is usually the case, they don't have any good pictures....

Here is the visualizer in action in an actual debugging session:


And here is what the dataset visualizer looks like with data:


Hope this post helps someone else find out how useful the dataset visualizer can be.

Issues with PDF files

One of my applications streams PDF files (or any other type the user hapens to upload as an attachment).  Prior to the Adobe reader 9.4.2 update, the browser never had an issue

displaying the file.  After the update, the browser would no longer display the file, it would only allow the user to save the file to their hard drive and then open it up.  The dialog

that was displayed to the user had an interesting message at the bottom: 


"The file you are downloading cannot be opened by the default program.  It is either corrupt or it has an incorrect file type.  As a security precaution it is recommended that you

cancel the download." 


I finally found a post on the Adobe forums today that has many different solutions from many different developers that have worked around the issue, and I was also able to resolve

the issue for my application by using bits and pieces of the solutions provided in the forum post ( 


Here was my code prior to the workaround: 


    Dim DR As SqlDataReader = SqlHelper.ExecuteReader(Utils.HPSConn, CommandType.StoredProcedure, "hold_ticket_item_attachment_view_by_id", New SqlParameter("@id", Attachment_ID))

    If DR.Read Then


     Response.ContentType = DR("mime_type").ToString

     'inline:  opens document in same browser window so that we do not have orphaned browser when done.

     'attachment:  opens in a seperate window, so we have an orphaned browser when done.

     Response.AppendHeader("Content-Disposition", "inline; filename=""" & DR("file_name").ToString & """")

     Dim file_data As Byte() = DR("file_data")


    End If


    DR = Nothing 


Here is the code that is now functioning as it should: 


    Dim DR As SqlDataReader = SqlHelper.ExecuteReader(Utils.HPSConn, CommandType.StoredProcedure, "hold_ticket_item_attachment_view_by_id", New SqlParameter("@id", Attachment_ID))

                If DR.Read Then




                    'inline:  opens document in same browser window so that we do not have orphaned browser when done.

                    'attachment:  opens in a seperate window, so we have an orphaned browser when done.

                    Response.ContentType = DR("mime_type").ToString

                    Response.AppendHeader("Content-Disposition", "inline;filename=""" & DR("file_name").ToString & """")

                    Dim file_data As Byte() = DR("file_data")



            End If


                DR = Nothing 


You'll notice the only 2 changes I made were to add the lines in bold. 


Seems the changes (in Adobe Reader or the browser or whatever changed to cause this behavior) are "fixed" by making sure the response stream is clean and is properly terminated. 



DevExpress AspxGrid – calculating grand totals (column totals) in the footer when dynamically generating columns

If you read yesterday’s post, you know I was having a hard time with a report that uses an AspxGrid to display the data.  I solved the problem that was causing an error when I did a postback and the number of columns had changed, but then I started working on adding totals to the footer and ran into another issue. 


I couldn’t figure out for the life of me why I could specify a column by name and add the total, but when I tried to determine the column names (since they are dynamically generated) so that I could add the totals (that is how you do it with the DevExpress AspxGrid), the footer was always blank. 


I finally figured out the issue was a timing issue.  If I try to set the totals up after databind, they do not show up because that is when the control actually calculates the totals.  I couldn’t figure out how to get the names without databinding either, so I thought I was stuck.  Then, the light bulb flickered.  I decided to just look at my datatable (since it has the field names I am using in it) before I do the data bind and setup the totals. 


DevExpress has some good examples of how to set up the totals in the footer, just none that help you figure out the column names when you don’t know them. 



GiveCamps – A great way to volunteer

I am participating in the Dallas GiveCamp next weekend (1/14 – 1/16) and attended the orientation meeting last night.  At the meeting we heard information about what happens during the weekend and what will be expected as well as information about all of the charities that are part of the event. 


I have been interested in volunteering for a couple of years, but the weekend was always a bad one for me.  I am glad this year the weekend is one where I do not have any prior commitments.  However, I was a bit unsure of the whole 1 weekend to develop a working application aspect of the event, but after the meeting last night I am excited to be a part of it and feel the team I am on will be able to do some great things. 


If you are in the Dallas area and have free time over the weekend of 1/14, please go sign up.  I am sure they will still accept volunteers. 


I’ll post at least one update after the event to let everyone know how it went. 



DevExpress AspxGrid – issues when dynamically determining the columns at runtime

For anyone else who uses DevExpress AspGrid control, this may help you get past an issue if you are dynamically generating the columns and there is a possibility your number of columns will change with each postback. 


I wasted about 30 minutes today trying to figure out why I was receiving errors the second time I ran a report (with different criteria).  One of my co-workers found this link: 


Two things I took away from this: 


1)      I didn’t know DevExpress had a facebook page that actually had useful information on it. 


2)      I love DevExpress products, but I sometimes don’t like the little quirks that come along with them. 



String Formats - the best cheat sheet ever!

Saw a blog post today that mentioned this excellent cheat sheet for string formatting options.  A definite must have piece of cubicle art. 



SQL Server Compatability Settings and Table Valued Functions

I had an issue today where an outer apply on a table valued function kept giving me strange errors.  After wasting about 30 minutes trying to figure out what I had done wrong, I Googled it and found a few small passing references to the database setting (under properties - options) for compatability mode.  Sure enough, when I looked at the setting, it was set for SQL Server 2000 (80) and this is a 2005 database.  When the DBA upgraded our databases from 2000 to 2005, he "forgot" to change this.  I had him make the change and now the outer apply with a table function now works. Cool

Pager Control

This one is too good not to keep track of.... 


Rick Strahl always comes up with great stuff, and this is definitely an excellent implementation of a pager control: 



ViewState Error - not really a viewstate error

I have been banging my head on the desk with an issue for the past couple of days.  Thanks to Dan Maharry's blog, I have finally solved the issue. 


(Just wanted to keep this here for future reference) ajax client-side framework failed to load

Ran into this issue when promoting an upgrade from dev to staging today. 


The site was upgraded from 2.0 to 3.5.  I searched all over and found a lot of answers, but the final fix was to add 2 0 (zero) byte files in the root of the website:  ScriptResource.axd and WebResource.axd. 


Go Figure.... Surprised


I assume if I were to create a brand new project in VS 2008 it would add these 2 files and the upgrade process does not. 
Oh well.  At leaset my web server admin had written down a note when someone else ran into the same issue.