blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

Rory Street's Blog

Do you want fries with that?

  • Rename Outlook 2007 folders

    I recently had a strange issue with my Outlook inbox being renamed to that of a document I had just emailed from Word. I wasn't able to rename the folder and discovered the only solution was to start up Outlook with the following command line.

    "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE" /resetfoldernames

    This set all of my system folders in Outlook back to their default names.

  • Sitecore Xpress

    Sitecore a .NET content management system I have spoken about on several occasions, have released a light weight version of their content management system called Sitecore Xpress. Sitecore Xpress is free for use on your personal site and is targeted towards developers. Signing up for Sitecore Xpress will give you access to Sitecores Developer Network which enables you to download the latest Sitecore modules and interact with other developers on chat forums for advice, tips and the sharing of code.

    Sitecores approach on releasing a "free" version of their software should help to spread its popularity among developers helping them to experiment with the software and create new functionality for it. Similar to the approach used by open source content management systems such as Joomla.

  • Paging filtering,searching and sorting in one stored procedure

    Putting all the above into one stored procedure has often been a TSQL dynamic nightmare putting together various bits of SQL strings and executing them. Looking around the web I have found various examples but not for all of what I wanted to do in one procedure. There were examples for paging, filtering and sorting but all as separate examples. Since I finally managed to put these all together I thought I'd blog about it, more for my own reference than anything else. But if it works for you and you have any improvements or suggestions I would love to hear from you.

    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go

    -- =============================================
    -- Author:        Rory Street
    -- Modified date: 10 Jan 2008
    -- Description:    Get Products with optional keyword search sorting and paging.
    --
    -- =============================================
    ALTER PROCEDURE [dbo].[GetProductsWithPaging]
        @StartRowIndex int = 0,
        @MaximumRows int = 10,
        @SortCol varchar(100),
        @SortDir varchar(5),
        @AmountFrom decimal(38,11)=null,
        @AmountTo decimal(38,11)=null,
        @KeyWordSearch varchar(200)=null

    WITH EXECUTE AS CALLER
    AS
    BEGIN

    SET NOCOUNT ON;
    with TableCTE as
    (
        SELECT TOP 500 ProductSKU,ProductTitle,ProductDescription,Price,Category
        (ROW_NUMBER() OVER (Order By
        CASE WHEN @SortCol='ProductTitle' AND @SortDir='DESC' THEN ProductTitle END DESC,
            CASE WHEN @SortCol='ProductTitle' AND @SortDir='ASC' THEN ProductTitle END ASC,

            CASE WHEN @SortCol='ProductDescription' AND @SortDir='DESC' THEN ProductDescription END DESC,
            CASE WHEN @SortCol='ProductDescription' AND @SortDir='ASC' THEN ProductDescription END ASC,

            CASE WHEN @SortCol='Price' AND @SortDir='DESC' THEN Price END DESC,
            CASE WHEN @SortCol='Price' AND @SortDir='ASC' THEN Price END ASC,

            CASE WHEN @SortCol='Category' AND @SortDir='DESC' THEN Category END DESC,
            CASE WHEN @SortCol='Category' AND @SortDir='ASC' THEN Category END ASC,

        )) AS Row
        FROM tblProducts
        WHERE
        ((@KeyWordSearch is null) or (ProductDescription like @KeyWordSearch))
        AND
        ((@AmountFrom is null) or (Price >= @AmountFrom ))   
        AND
        ((@AmountTo is null) or (Price <= @AmountTo ))   
    )   
    select * from TableCTE
    WHERE
            Row
        BETWEEN
            @StartRowIndex +1 
        AND
            @StartRowIndex + @MaximumRows   

    END

    How it works
    The thing I like about the above example is it does not use dynamically created SQL. I have deliberately used a basic example above of a simple product table that I wish to sort, filter and search from my product page. To make things a bit more interesting my product page is actually a WCF client (don't worry you can still call this procedure directly without WCF). As you can understand it doesn't make sense to download all of the data when using WCF and then trying to page and sort the data. You would create an interface that would accept paging and sorting and this stored procedure works pretty nicely with that type of concept. The stored procedure uses the Row_Number internal function to assign each rows with a unique sequential number based on the column we are sorting by which is handled by the CASE statements which works out which column we wish to search by using the @SortCol parameter. 

    Paging is done by using the @StartRowIndex and @MaximumRows parameters. So for example if you wanted to page through your data with 10 records per page. Page ones settings would be @StartRowIndex=0  and @MaximumRows=11 for page two the settings would be @StartRowIndex=10  and @MaximumRows=11. Now you're probably wondering why I make the maximum amount of rows 11? The reason for this is that when I load the data on the client I will only display 10 of the rows if I get back 11 though, I know there is another page with at least 1 record so I can show my "Next Page" button on the client.

    Note
    This example will only work with SQL Server 2005 as it uses a CTE method.

  • How to check if Visual Studio 2005 SP1 is installed

    The below is more for my own reference so I don't forget it:

    Check the following registry key.

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\VS\Servicing\8.0

    Check if the SP value is 1.

    Check your Visual Studio version from the Help > About menu is set to

    Version 8.0.50727.762

    Posted 10 August 2007 12:39 by rory.street | 2 Comments
    Filed under:
  • Issues connecting TFS Server

    I was having problems connecting to the TFS server from my machine and no one else appeared to have the same issue from their machine. Half way through pulling out my hair, I noticed MS Fiddler was open. After I closed it, like magic I could reconnect back to TFS!

    Posted 20 June 2007 12:26 by rory.street | 0 Comments
    Filed under:
  • MSBUILD issues with web site projects

    The following is more a reference for myself so that I don't forget it. I've been battling with a build script that's being deployed using a WIX installer and get the following error.

    Task "Web.WebSite.CreateVirtualDirectory"
    error : Message               = Exception from HRESULT: 0x80005000

    The solution to the problem was pretty simple in my web installer I had put the name of the virtual directory of the project with a trailing backslash \website when all I should have done was quite simply put website.

    Technorati Tags:
    Posted 13 June 2007 11:20 by rory.street | 0 Comments
    Filed under:
  • Co Browse

    This is a little app I created to make comparing changes between live and staging versions of web sites easier for some of our testers and us poor dev's who get told something doesn't look right on the test server but looks fine on the dev box ("it works on my machine!").

    Its pretty simple, all it does is take two URL's from the user and then shows the user two embedded browsers in the application. What ever the user clicks on in the top browser gets browsed in the bottom URL. So for example if I put the URL http://www.conchango.com in the top browser and then http://testcomsite in the bottom URL browser. If I navigated to say http://www.conchango.com/Web/Public/Content/AboutUs/AboutUs.aspx the browser below will navigate to http://testcomsite/Web/Public/Content/AboutUs/AboutUs.aspx , or attempt to load the same page on that site.

    My latest version of this application now includes a plugin that enables users to browse Mozilla and IE pages side by side using a Mozilla ActiveX plugin I found here. I will shortly be uploading the binary and code for this simple app after I've packaged it up. If anyone has found a more up to date Mozilla ActiveX plugin that is more recent than 1.7 I'd love to hear from you.   

  • Using custom membership providers with custom login controls

    Recently I had to create a custom membership provider for a client which required authentication through two user ids and fragments of the users password. You can understand that using the Logon control that comes out of the box with ASP.NET 2.0 will not accommodate this membership provider, so I went about creating my own form control to submit the data to the membership provider I created.

    All worked fine however I couldn't for the life of me figure out how to actually set the users Context.User.Identity.Name which will basically allow you to identify the user once logged in. This is something the log in control does automatically for you that you don't usually have to think about, anyway the simple line of code is below.

    FormsAuthentication.SetAuthCookie(userName, false)

    Posted 04 June 2007 20:11 by rory.street | 1 Comments
    Filed under:
  • TFS Working offline

    I've never really used TFS Source control offline before and have been in more projects where I have used the latest version of Visual Source Safe. In comparison TFS source control seems a lot more rich in features, sadly its missing one key feature that Source Safe was very good at and that's the ability to easily work offline and then check what ever changes you had back in and merge them with source safe.

    I've found an interesting webcast on how to work offline with TFS using TFS Power Toy. 

    Posted 03 June 2007 15:32 by rory.street | 0 Comments
    Filed under:
  • Windows Live Writer

    I've just been reading my colleague Jamie Thomson's blog about Windows Live Write beta 2 I've recently started using it myself and hurried to download the beta 2 version, hopefully now I could start using an English UK dictionary instead of a English US dictionary when writing blog posts (colour shall always have a u in it!). But alas the installer only installed the beta 1 version again and didn't give me the option to use a UK dictionary. Argghhh! I really love Windows Live Writer I'd just like the option to choose what dictionary I use.

  • MS LINQ

    At our Friday community day I got to see a demonstration of MS LINQ by Mike Taulty. Being rather busy on projects I haven't had much time to look at it in any detail but Mike's demo of LINQ was enough to amaze me on how easy it was to use LINQ to do direct SQL query's from a .NET language without the need for worrying about creating a data layer with ADO calls. The power of LINQ to also run against business objects, arrays and XML with a simple query language similar to SQL (but without the double quotes et al) was fascinating.

    The LINQ demo raised some interesting questions for me I could just imagine trying to implement it on a project and my DBA looking at me and saying "No way! I control that I make the stored procedures you need to put data in and take it out of SQL not LINQ!". I would then say "Yes but with LINQ you can still make the stored procedures and we will just use that". The DBA would then look at me skeptically "Mmm I'm not convinced.."

    The DBA aside there are probably other things that need to be taken into account.

    1. How will best practices for architecting solutions change? In many best practices we've always been thrown the basic principle of keeping the presentation separate from the business logic and then business logic separate from the data layer and the knee bones connected to the thigh bone etc..
    2. Will ADO suddenly dissolve into LINQ or will many database providers out there suddenly develop LINQ drivers to make it that much easier for us to slip into this cool technology?
    3. Will there be a performance hit? Talking to Mike he informs me that Microsoft are attempting to fine tune LINQ so that using it or ADO will be appear almost identical in speed.

    I personally can't wait to try it out on a new project!

    Posted 02 June 2007 19:09 by rory.street | 0 Comments
    Filed under:
  • Issues using MSBuild with Cruise Control

    I've often had issues getting an automated build process to run correctly with Cruise Control and MSBuild. It seems that when ever there is more than one project file introduced into the solution you start getting issues with your automated build server. What usually ends up happening is you end up installing Visual Studio on the Build server to figure out why its not building and in most cases its MSBuild getting those binding wrongs between the various projects when it gets the latest version of your solution out of version control.  What I found actually helped was to actually check out the solution file on the build server create the proper bindings and then check the file back in, its seemed once I had done this it would remember the bindings and not re do them every time I did a build. It seemed odd but the actual binding information appears to be stored locally outside of the solution and proj files that are checked into source control which I found rather odd.. oh well its works..

    Posted 02 June 2007 18:25 by rory.street | 0 Comments
    Filed under:
  • WCF Automation Package Host not working with Enterprise Library

    I've recently started having the following error with an Automation Package for WCF I have been writing when calling the host from a client.

    "Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data' or one of its dependencies. The system cannot find the file specified."

    The only way I have been able to solve this error is by placing the Microsoft.Practices.ObjectBuilder.dll inside the bin folder of my host project for the time being. I am wondering why the Guidance Automation Package didn't place this into the bin folder of the host automatically my theory is that this may need to be referenced from the GAC?

  • MS Access to SQL Server Express

    There are plenty of novice coders out there who would like to move their old style ASP applications based on an MS Access database to .NET 2.0.

    Its a great idea and it helps you learn how all those functions work in the .NET framework, and I would like to make the suggestion that if you are moving your applications across that you think about using MS SQL Server Express instead of MS Access. Its a lot more scaleable provides an easy upgrade path for your application to a full SQL Server install and whats more its free!

    The only thing putting people off the migration is how on earth do you migrate your tables to SQL Express as there is no import utility! Well the easiest way I have found is to:

    1. Go into the Access database you want to export from, select a table you wish to export and then select export from the file menu.
    2. In the "Save as type" box scroll down to ODBC Databases
    3. Select OK on the box that appears
    4. Now unless you have a DSN already setup to your SQL Express Database you will need to setup one here by clicking on NEW
    5. Scroll down and select SQL Server
    6. Then browse to where your SQL Server Express .MDF file is and there you go!

    Now the only down side in this approach is that you have to do this for each table! Ouch! If anyone has come up with a better way of doing this please let me know.

     

  • Getting ASP.NET AJAX 1.0 to work with Sitecore

    Just a quick note more for my future reference more than anything else.

     To get ASP.NET AJAX 1.0 to work with Sitecore you need to add the following to the ignoreurls section in your web.config

    <setting name="IgnoreUrlPrefixes" value="/trace.axd|/sitecore/shell/Editor|/sitecore/admin/upgrade/|UnhandledException.aspx|/webresource.axd|/ScriptResource.axd"/>

    to convert an existing web application to use AJAX.NET which you can find a tutorial on over here

More Posts Next page »
Powered by Community Server (Personal Edition), by Telligent Systems