Blogs

Paul Kimmel's Blog

August 2009 - Posts

  • Enabling and Disabling Script Debugging for IE8

         

    Visual Studio 2008 shipped with a feature to automatically enable script debugging when starting IE8 from Visual Studio. This means the old technique of selecting Tools|Options and switch to the Advanced tab or the Internet Options dialog and checking “Disable script debugging (Internet Explorer)” is not going to disable script debugging from your Visual Studio 2008 sessions. And, many times, given these conditions you want to be able to debug your script code.

    Unfortunately, according to greggm’s blog at--http://blogs.msdn.com/greggm/archive/2009/04/06/disabling-script-debugging-in-vs-2008-ie8.aspx for his post—this causes a problem. For web sites that create a large number of dynamic documents performance can get sluggish and there was no way to turn script debug off. Borrowed from his original post here are the steps to turn off script debugging:

    1. Open an instance of Windows Explorer.
    2. Change folders to c:\windows\system32
    3. Right-click on cmd.exe and click Run as administrator. This will start a cmd.exe session in Administrator mode
    4. Run your registry editor by type regedt32 at the command prompt
    5. Click on the root “Computer” and select Export to export (that is, backup) a copy of your registry
    6. Copy and paste the following text into the cmd window and press enter

    reg add HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {4FF9DEF4-8922-4D02-9379-3FFA64D1D639} /f

    Script debugging will now be permanently disabled on your PC. To re-enable script debugging repeat the numbered steps and enter the following command for step 6:

    reg add HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\AD7Metrics\Engine\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2} /v ProgramProvider /d {170EC3FC-4E80-40AB-A85A-55900C7C70DE} /f

    I tested the steps to see if they work and they seemed to work as advertised. If you have 64-bit Windows or are using Visual web Developer then the command strings and the version of the registry editor you use will vary slightly. Check out the original blog post for more information on the variations. I always like to know details. The /f switch for reg add forces an overwrite without a prompt of existing registry values, /v is the value name under the selected key, and /d specifies the data to assign the key. You can find out more about the reg command by typing reg /? at the command prompt.

    As always it is recommended that you save a copy of your registry before making any changes and routinely back up you PC and servers.

  • Book Update

         

    One more chapter to write, chapter 10, for Professional DevExpress ASP.NET Controls. So far it looks like there will be 13 chapters and one appendix with a page count around 500 pages. The book is scheduled to be out and available by PDC, but our controls are feature-rich enough that it could easily encompass another 500 pages.

    I am already working on establishing an errata page and forum support. If permitted in the fashion recommended book questions—any omissions or changes due to feature updates, etc—and customer/reader questions can be posted there. Revised, additional content and new demos will be added as the need or interest presents itself.

    The final steps are to write the remaining chapter, extensive editing, technical and peer review, and publication. Everyone at Developer Express has contributed extensively and the project could not have been undertaken and completed without their help. Of course, the final formulation is ultimately my interpretation of things you might want or need to know, examples, anecdotes, stories, facts, and supporting information that will ultimately make reading the book enjoyable as well as informative. (Responsibility for the content is my responsibility and you will be able to write me and rant or rave as the case may be at paulk@devexpress.com.)

    I feel gratitude and am indebted to everyone at Developer Express for their numerous and varied contributions. I will save the names for the acknowledgements. I look forward to seeing you at PDC in November.

    Paul

  • Finding the Median Value with MS Access SQL

         

    Developer Express provides tons of sample content for our customers. The sample content includes CSS, source code, databases, XML, graphics, and much more. I was writing a sample for a custom aggregate value for Developer Express’ upcoming book Professional DevExpress ASP.NET Controls to be published by Wrox and realized I didn’t know of an easy way to calculate the median value of a result set using Access SQL. (Calculating the median value with Access SQL is not what the book is about. :) The Access SQL is actually mentioned in the context of demonstrating how the ASPxPivotGrid can provide custom summaries, like calculating the median value. In effect letting users get answers to questions through the GUI.)

    Three of the tables the CarsDB.mdb database includes are Cars, Orders, and Customers. Cars and Orders are connected by Cars.ID = Orders.ProductID. The Orders and Customers tables are connected by Orders.CustomerID = Customers.ID. The figure shows the three tables used for the query.

    image 
    Figure 1: The three tables—Cars, Orders, Customers—used for the query to find the median value.

    The basic query that defines the columns to return, including the PaymentAmount, and the relationships between those tables is provided in Listing 1. It is the median PaymentAmount that I am calculating and to reduce the result set a WHERE clause is added to refine the query to Alessandro and Associates. The resultset can  be refined by adding WHERE Customers.Company LIKE ‘Ales*’. By ordering the resultset by PaymentAmount and grabbing the top 50 percent of items the median value will be included in the result data set (see Listing 2).

    Listing 1: This query returns all of the rows from Cars, Orders, and Customers and the columns specified in the SELECT clause.

    SELECT Cars.Model, Cars.Price, Orders.PurchaseDate, Orders.PaymentType, Orders.PaymentAmount, Orders.Quantity, Customers.Company, Customers.City
    FROM (Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID) INNER JOIN Cars ON Orders.ProductID = Cars.ID

    Listing 2: This query returns the ordered top half of the result set.

    SELECT TOP 50 PERCENT Cars.Model, Cars.Price, Orders.PurchaseDate, Orders.PaymentType, Orders.PaymentAmount, Orders.Quantity, Customers.Company, Customers.City FROM ((Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID) INNER JOIN Cars ON Orders.ProductID = Cars.ID) WHERE (Customers.Company LIKE 'Ales*') ORDER BY Orders.PaymentAmount

    The above query returns the top half of the data set. The median item will roughly be the last item in the result set. Next, if you reverse the order of the result set then the top most value will be the median value. (You could sort the results in the query in Listing 2 but then you would get the bottom 50 percent of the items in the complete data set.) The query in Listing 3 contains the result set with the median value as the first row.

    Listing 3: By selecting the result set again but reversing the order you get the median value as the topmost value of the result set.

    select * from
    (
    SELECT TOP 50 PERCENT Cars.Model, Cars.Price, Orders.PurchaseDate, Orders.PaymentType, Orders.PaymentAmount, Orders.Quantity, Customers.Company, Customers.City FROM ((Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID) INNER JOIN Cars ON Orders.ProductID = Cars.ID) WHERE (Customers.Company LIKE 'Ales*') ORDER BY Orders.PaymentAmount
    )
    order by PaymentAmount desc

    Finally, query the results in Listing 3 and request the TOP 1-th value. The final query in Listing 4 will return the median value (or pretty closely if the result set has an even number of items). I am not saying that three nested SELECT statements will be an efficient query to run often or against a lot of data. It will return the median (or middle) value in a result set. I tried some shorter versions and variations on the final query. For example, the TOP 1 modifier was added to the SELECT * FROM—the middle SELECT—but placing it there actually returned three rows containing similar values; I just wanted one and the query seems to work.

    Listing 4: The final query—its not efficient or pretty but it seems to work.

    SELECT TOP 1 * FROM
    (SELECT * FROM
    (SELECT TOP 50 PERCENT Cars.Model, Cars.Price, Orders.PurchaseDate, Orders.PaymentType, Orders.PaymentAmount, Orders.Quantity, Customers.Company, Customers.City FROM ((Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID) INNER JOIN Cars ON Orders.ProductID = Cars.ID) WHERE (Customers.Company LIKE 'Ales*') ORDER BY Orders.PaymentAmount) ORDER BY PaymentAmount DESC)

    I am not saying that this is the kind of query you routinely should or want to write. In this instance it may not even be a great query. If you are writing an Access query to calculate the median value and you have no solution then try this one. This query is actually used as a negative counter pointer in the upcoming Professional DevExpress ASP.NET Controls book. The point mentioned in the book is that if your users have a requirement whether spoken or unspoken then they may cobble an ad hoc solution together. The section this query appears in covers custom summaries in the ASPxPivotGrid. The ASPxPivotGrid has several built in summary types and supports a custom summary event handler, letting you implement your own custom events.

More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.