Wednesday 9 October 2013

Move from iGoogle to Netvibes

Still annoyed at Google for switching off iGoogle at the end of the month.  So much for their, "Don't be evil," motto! I have however found a good alternative after a brief flirtation with Protopage.com!

Netvibes.com is good (so far) and has allowed me to replicate my iGoogle page (that I spent years refining) in the space of a few hours.  Most of it was set up pretty quickly after following some instructions on the Netvibes blog (http://blog.netvibes.com/from-igoogle-to-netvibes-in-3-easy-steps/).  Note:  I had to manually edit the OPML XML file to remove non-RSS feeds to get it to work properly.  If you can't do this you'll need to remove them from your iGoogle pages before you export.

I've managed to get Gmail and Google Calendar working relatively quickly.  The thing that took the time was trying to replicate Google Finance.  Unfortunately I couldn't link in my Google Finance portfolio, but have found a reasonable stock widget called, "StockWidgets."  Its not as good as google's offering, but if you add a bookmark to your page to Google Fiance you can get there quickly anyway.

You'll probably need to set up 2 step verification to get Gmail working, luckily I'd already been down that route with Protopage.

So, if you need an alternative to iGoogle then I think Netvibes is the way to go!

Tuesday 30 October 2007

When Aliasing columns in SQL Server - don't use an actual column name

Stumbled across an interesting quirk in SQL Server.
I had a column called, "CallReference," which is a bigint. I wanted to pad the number with zero's to the left. So, 123 would become 00000123.

I did this:
cast(replicate('0', 8 - len(cast(callreference as varchar(8)))) + cast(callreference as varchar(8)) as varchar(8)) as CallReference

The strange thing is that by the time it got to my DataTable is was always treated as a number (depite me adding a cast as varchar).
The problem was caused by me using a column name as my alias that actually existed in the table. When I changed the name it would come back as string and be correctly padded in the DataTable.

Tuesday 16 October 2007

WPF & Silverlight Presentation

Tonight I went to a .NET Developer Network presentation on WPF and Silverlight. Oliver Sturm did a fantastic job of presenting. He certainly knows his stuff.

It seems to me that Silverlight is still a little way off from replacing AJAX as the rich client of choice on web browser. I'm convinced it will get there though, probably starting with Silverlight the the release after version 1.1. At the moment you have to reply on 3rd Party WPF controls, as MS don't ship any! I can't wait for the day when I don't have to write anymore JavaScript!

WPF as a replacement to WinForms looks ready to go. I was very impressed at how easy it is to write forms that will scale properly at different screen resolutions. The data binding also sounds good... but I've heard that one from MS too many times before!

To cap off a good night I managed to win a pair of MS socks. A couple of developers were waiting to jump me outside but I managed to give them the slip :-) Still, they'll probably work better than the free copy of Vista Ultimate someone managed to bag.

I genuienly feel inspired to start using WPF ASAP.

PS Thank god for Sky+... as I didn't even miss Spooks.

Friday 12 October 2007

Title (InitCaps) Case Function

An easy way to make a string title case.

public static string TitleCase(string strText)
{
return new CultureInfo("en").TextInfo.ToTitleCase(strText.ToLower());
}

Tuesday 25 September 2007

Using DataAdapter.Update on DataTable when using a BindingSource

I had a weird problem this week that took me hours to resolve. I had created a BindingSource so that I could set up DataBinding for controls on my form. Everything bound correctly and updated the DataTable.

...but everytime I called DataAdapter.Update on the DataTable it would complain that a particular foreign key field was null - even though I could see the value in the DataTable using the DataSet visualizer!

After simplifying my solution in a test project and adding to it incrementally to see what was causing the problem I stumbled across the answer.

I was doing this:
DataRow drow = myDataTable.NewRow();
myDataTable.Rows.Add(drow);

This approach has worked for me many times, hence the amount of time I spent finding this solution:

myBindingSource.AddNew();

So, it turns out, if you use a BindingSource you have to call it's methods for CRUD operations!

Weird, I'm sure this is a bug. I even checked the RowState using the old method which told me that I had added the row.

If anyone can explain this behaviour I'd be interested to hear it!

Thursday 6 September 2007

Combining Paths

How many times have you written code to concatenate a file name to the end of a path? How many times has this failed because you either forgot to add the back slash or put in too many slashes?

The following code will do the check for the back slashes for you and append one if necessary:

Path.Combine(path1, path2)

This is particularly handy if the paths come from user input.

Nice! No more checking the last character of the string for a slash!

Friday 17 August 2007

Truncating a string in C# - Easy huh?

I had an interesting issue this morning, it sounds really simple... All I wanted to do was make sure that a string was 10 charactors or less. Easy huh? Just use substring!

mystring = "Hello";
string newstring = mystring.substring(0,10)

Wrong!

substring will fail with an exception because mystring doesn't have 10 characters.

Here is a neat solution:

string newstring = mystring.Substring(0, Math.Min(mystring.Length, 10));

James