Friday, 12 September 2008

How to turn [master].dbo.[xp_cmdshell] on - SQL Server 2005/2008 ...

EXECUTE sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
EXECUTE sp_configure 'xp_cmdshell', '1'
RECONFIGURE WITH OVERRIDE
GO
EXECUTE sp_configure 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
GO

Thursday, 11 September 2008

One I learnt the hard way ...

Don't use a 32-bit int to represent a phone number.

When I first started writing code for telecommunications applications, I used int all over the place in my TSQL. I soon clicked that this was not such a good idea (prior to any chaos being caused), and went around swapping out my ints for varchars. Unfortunately I didn't get them all ...

In NZ, the longest mobile phone numbers we have had for quite some time have been 10 digits, starting with 02 - so like 0275555555 would have been a long-ish one. As I have noted due to recent 'issues' arising with one of my real-time systems, we have recently moved (in NZ) to include 11 digit mobile numbers. Which pushes my dodgy code into exception (largest signed 32-bit int being 2147483647).

Great, so that kept me very busy for a couple of hours yesterday, extracting the remaining phone number ints out of my TSQL. Sometimes we learn lessons the hard way I guess ;-)

Friday, 5 September 2008

Microsoft SQL Server 2008, Database Development

There is now an MCTS exam directed specifically toward database developers (like me!):
 
 
Looking forward to giving this one a go ...
 

Wednesday, 3 September 2008

WPF: use IValueConverter to implement dynamic binding to an XML data source ...

Here are some swift details on how to use IValueConverter to implement dynamic binding to an XML data source.

 

Add the XML source to your XAML page/window as a resource. Also add your URL converter that gives you customises your input. You could use XLINQ here to get some nice thingie going. I'm using it for manipulation of a static application map:

 

<Page.Resources>

<XmlDataProvider x:Key="ApplicationMap" Source="ApplicationMap.xml"/>

<src:PageURLConverter x:Key="pageURLConverter"/>

</Page.Resources>

 

Make yourself a Frame and use the XML source and the converter to build the URL that the Frame will hold:

 

<Frame

Name="frameContent"

Source="{Binding XPath=@PageLink, Converter={StaticResource pageURLConverter}}"

NavigationUIVisibility="Hidden"

Focusable="False">                   

</Frame>

 

The converter looks like this:

 

public class PageURLConverter : IValueConverter

{

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

    {

        string url = (string)value;

        if (url.StartsWith("http://")) return YourURLManipulateMethod(url);

        else return url;

    }

 

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

    {

        return value;

    }

}

 

I used this method in a CRM-type application to whack an Account Code on the end of a URL query string. Allowed me to load a pre-existing ASP.NET component of the CRM into a Frame in the WPF app for the same account the user was working with.

 

Tuesday, 2 September 2008

SQL Server 2008 and Spatial Data ...

DId a bit of a talk at the most recent Code Camp event in Auckland City. My talk centred around spatial data, and how it is used in the telecommunications industry.

I've been doing a bit of research in relation to this matter recently and found that Microsoft have finally published a nice big section of MSDN stuff dedicated to how to use the spatial data components of SQL 2008. Looking forward to getting stuck into that!

http://msdn.microsoft.com/en-us/library/bb933876.aspx

Migrating (and Open-Sourcing) an Historical Codebase: SVN-to-Git

I have a SVN repo on my local machine that I have been shoving stuff into since before I knew how to use revision control systems properly (...