Microsoft SQL Server has the ability to format the query output to xml, which is great. I used version “Microsoft SQL Server 2008 (SP3) - 10.0.5500.0 (X64)” to output XML to have a nested data structure, but there is unfortunately no first citizen support for JSON which is big on the web these days. Perhaps it is left out on purpose to make sure that people are unable to direct output their data as JSON and are forced to build a layer in between so that it can also authenticate and add security to a request. Web API is great for this. But back to the subject: I wanted to output my nested data as JSON really quickly with the minimum amount of code.

In a nutshell, I got the data as xml and converted that to JSON and send it to the output of a generic handler (*.ashx)

Here is my source code for my easy SQL2JSON solution:

private XDocument GetProducts(string q)
    SqlCommand comProd = new SqlCommand(@"SELECT ProductCode, ProductEan13, CategoryName FROM PRODUCTS 
        inner join CATEGORIES on products.CategoryID = CATEGORIES.CategoryID
        WHERE ((FactoryCode LIKE @name) OR (ProductCode LIKE @name)) AND (ProductDeleted = 0) for xml raw ('Product'), ROOT ('Products');");
    comProd.Parameters.AddWithValue("name", q + "%");
    string xml = SsDb.GetScalar(comProd).ToString();
    return XDocument.Parse(xml);

This gave me an `XDocument` object which I still have to convert to JSON

Since I was using an generic handler I retrieved the search parameter from the query string and used it as input parameter for the `GetProducts` method.

public void ProcessRequest(HttpContext context)
    context.Response.ContentType = "application/json";
    context.Response.Cache.SetMaxAge(new TimeSpan(24, 0, 0));

    string q = context.Request.QueryString.Get("q");

So the most important line is the last one:


Do not forget to use the one-nuget-package-that-rules-them-all (Install-Package Newtonsoft.Json)

using Newtonsoft.Json;


Now you can access your JSON data source with the C# generic handler from your JavaScript


I hope this has been of any help. good luck!

Pin on pinterest Plus on Googleplus Post on LinkedIn

The first step is of course install the remote debugging tools on the debug host http://msdn.microsoft.com/en-us/library/bt727f1t.aspx#BKMK_Installing_the_Remote_Tools 

When I fire up the Visual Studio Remote Debugging Monitor (latest version 12.0.30501.0), it says that it is already running on port 4018 so I have selected a different port. I selected 4019 and went to the “Tools” menu and then “Options (Ctrl + o) I have selected 'No authentication' and check 'allow any user to debug'. 

All there is left to do, is press play on the Visual studio side and make sure that you have the same port and no-auth set.

The other option is not to go to options but go to permissions (Ctrl + p) and add my Live ID/ Microsoft account from my developing machine, but that takes more clicks and my debugging device also forgets these settings. So you have to set it at every launch. Since I am also the admin of this tiny LAN, there is no security risk here and I can go with option 1.

screenshot taken from the interwebz

I am able to remotely debug, it's just that I have to setup the debugging every time on the client side (Lenovo Miix 2 8" tablet running win8.1) The development side does not need to be reconfigured every time.

After spending some time on google/bing/duckduckgo I have found http://msdn.microsoft.com/en-us/library/bt727f1t%28v=vs.71%29.aspx which gives me details about launching the remote debugging monitor from the command line and give it some parameters.

I ended up with a small .bat file having these command line options:

`msvcmon -anyuser -noauth -port=4019`

Here is a good read with more info about remote debugger settings:

Good luck debugging!

Pin on pinterest Plus on Googleplus Post on LinkedIn

Apple’s keynote was yesterday and revealed the iPhone 6, iPhone 6 plus, Apple watch and Apple pay. (Note: no iPay and iWatch) But I was a bit disappointed about the iPhone 6. It is not that high end as you would expect for the price that they charge. I know that in the USA about 30% of the people have an iPhone, but in the rest of the world it is about 10% market share. iOs is at this moment the number two mobile operating system and in Italy is it nr 3. Please do not get me wrong, I really like apple products and the fact that they make a lot of not technical people think about options. Before Apple was popular in the Netherlands everybody just went with Windows and did not consider other options (mac, bsd, linux etc.) So let’s just compare the iPhone 6 with the Lumia 830:

iPhone 6Lumia 830
iOs 8Windows Phone 8.1 with Denim update
4.7 inch5 inch
4g lte4g lte
1334 x 7501280 x 720
Optical image stabilization
1.2mp front cam0.9 mp front cam
no wireless chargingwireless charging
fingerprint readerno fingerprint reader
16 gb16 gb
no expansionmicro sd
799 usd426 usd

A few questions you have to ask yourself

There are a few questions you have to ask yourself when you are spending at least 800 dollar.

A 64gb micro sd is available for about 26 euro and 128gb is 88 euro. Retail price that is. How much would Apple pay for the extra storage? Is it worth 100 dollar to double the storage?

The camera of the iPhone 6 or iPhone 6 plus is only 8mp. The plus has optical image stabilization, but the regular iPhone 6 has not.

If you do not want Windows Phone, you can Also consider Android (of course) 4.4 with the Samsung Galaxy S5. It has a fingerprint reader, can have wireless charging with an extra cover. has a 16mp camera and you can expend the storage with micro SD. It is (in the Netherlands) available from 450 euro. Which is almost half the price of an iPhone 6 (800 dollar minimum).</p><p>As I said before, I really like Apple products, but I believe that Apple has out priced themselves. I would have expected more hardware or lower prices or a combination of both. What do you think dear reader? Don’t compare the CPU and RAM, because that is tied to how a mobile operating system manages it and can only be “measured” by a lagging interface, which is not the case at either iPhone6, Nokia and Samsung models mentioned above. The iPhone 6 was just announced yesterday, so I do not have hands on experience and if I have missed a thing or two, let me know!
Pin on pinterest Plus on Googleplus Post on LinkedIn

This post covers storing and retrieving settings with a WPF combobox for the UI. If you are looking for a solution to store settings across devices, for instance a Windows Surface tablet and a Windows Phone powered device, you should check out the blog of Mike Taulty. That is called roaming data storage. And if you are not working on an app for Windows RT/metro or Windows Phone but are just coding some WPF application, you should read this post from Scott Hanselman.

Let’s start with some code now that it’s clear what this post covers and what it doesn’t cover.

Here is my XAML from my userinterface:

<ComboBox x:Name="cbCountry" 
    PlaceholderText="Select country" SelectedValuePath="Tag">
    <ComboBoxItem Content="Australia" Tag="au"/>
    <ComboBoxItem Content="New Zealand" Tag="nz"/>

Please note the ‘SelectedValuePath’ is being set to ‘Tag’, otherwise it would grab the ‘comboboxitem’ or ‘content’ like this:

var comboboxContent = ((ComboBoxItem)cbCountry.SelectedValue).Content;

With the value path set to tag, it will grab ‘au’ or ‘nz’ as selected value.

This is the constructor of the xaml page containing my settings.

var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;


if (localSettings.Values.ContainsKey("country"))
    cbCountry.SelectedValue = localSettings.Values["country"];

and this is the code for the selectionchanged event of the combobox.

private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
    var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
    localSettings.Values["country"] = cbCountry.SelectedValue;

Good luck with this small code sample. If this is not what you are looking for, please check the links mentioned at the start. I strongly believe that they take you to the code that you are looking for (if the code above is insufficient)

Pin on pinterest Plus on Googleplus Post on LinkedIn

The Lenovo Miix 2 tablet is great if you look at the value you get for your money. I purchased one for work for just 196 euro at paradigit.nl


It took me a day to install all updates on the windows 8.1 machine. When I returned at work the next day the tablet did not boot. It was still on the usb charger so it was not a battery drain or empty battery or whatsoever. I tried to contact Lenovo through twitter, but no response (yet).

So I had to figure it out myself and found this blog with tips. One of them is to plugin the USB cable, wait for the white light and power on. That did not work. Power on before removing USB cable also did not work. Maybe this works for you, please let me know in the comments.

The real solution (for me) was this trick of @marauderz:

Hold the power button for 20 seconds and then release and press again. That does show the lenovo logo and makes the tablet boot again. It does not matter if you have the 8 inch or 10 inch device. According to @marauderz it has to do with "ConnStandby" mode which is the "connected standby" feature of windows. More about it is available on MSDN. This superuser answer explains how you can disable this feature. Since I am developing a universal app on this tablet and have it on an USB powercable 24/7 I do not need this connected standby feature. So launch regedit, go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\

and change ‘CsEnabled’ from 1 to 0. Confirm, close regedit and reboot.

Pin on pinterest Plus on Googleplus Post on LinkedIn