Blog Home  Home Feed your aggregator (RSS 2.0)  
.Net Jonesie - Tuesday, August 02, 2005
A simple programmers blog
 
# Wednesday, August 03, 2005

I don't want to burst anyones bubble here, but I think there's a lot of people under the impression that SQL 05 & VS 05 are going to be released on November 7th.  From everything I've seen announced, this is the LAUNCH date, not the RELEASE date - they could be quite seperate things.  At the very least, I wouldn't expect to see DVD's/CD's in your mail box before December. 

But then, I could be wrong... and it wouldn't be the first time.

Wednesday, August 03, 2005 9:04:29 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [2]   General | SQL | Visual Studio  | 
# Tuesday, August 02, 2005

I have a DataGridView where I allow users to type in cell values, but I only want upper case.  To do this, you need to capture the control as it's being created and assign a KeyPress handler.  E.g:

    private void MyGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
    {
      if (e.Control is DataGridViewTextBoxEditingControl)
      {
        e.Control.KeyPress += new KeyPressEventHandler(Control_KeyPress);
      }
    }


    void Control_KeyPress(object sender, KeyPressEventArgs e)
    {
      e.KeyChar = e.KeyChar.ToString().ToUpper()[0];
    }

Of course, you can extend this further to do all sort of things, but if your requirements are complex then it's probably advisable to create your own custom column.

Tuesday, August 02, 2005 10:09:30 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [2]   Visual Studio  | 

I like IE7, it's clean and fast and seems pretty stable.  HOWEVER, Work Item Tracking in Visual Studio 2005 Team Suite does not like it.  It causes VS to crash.

Luckily it uninstalls nicely and restores IE 6 as it was, so no harm done.

Tuesday, August 02, 2005 9:37:18 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   General | Team System | Visual Studio  | 
# Monday, August 01, 2005

Last week I had a small disaster with the source control in Team System.  I managed to overwrite 3 files and lost about 2 weeks work.  The files has not been checked in correctly since mid June.  This was not a nice thing to happen :{

For some reason known only to - pick your God here - I mucked around with the file attributes on these files and then did a "Get Latest", which of course, overwrote the local versions with the old server versions.  Yes, that was a stupid thing to do!  However, I still haven't a clue why the files where not getting checked in correctly.  It may have something to do with the readonly file attributes being out of sync or something else.

So, a word of warning, don't get too comfortable with the Source Control yet - IT'S A BETA !!!  Go and check now that all your files are being checked in correctly and before doing a Get Latest, backup your local versions.

Roll on beta 3...

Monday, August 01, 2005 8:45:45 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   Team System | Visual Studio  | 
# Wednesday, July 20, 2005

After logging in, be sure to visit all the options under Configuration in the Admin Menu Bar above. There are 26 themes to choose from, and you can also create your own.

 

Wednesday, July 20, 2005 7:00:00 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   dasBlog  | 
# Tuesday, July 19, 2005

I'm not the most efficient coder.  Things like Resharper are a waste of time for me.  I prefer to repeat myself 4 million times rather than learn 23,000 keyboard shortcuts.  I think it's something to do with creative flow.

However, sometime you see things that are so easy and quick to use that you just adopt them without thinking.  Snippets are one of these.  David reminded me of this.

So, here's a custom snippet I created for inserting properties. This is pretty much the same as the default prop snippet, but I've added summary comments and I like my member vars to have a leading underscore:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
 <CodeSnippet Format="1.0.0">
  <Header>
   <Title>jprop</Title>
   <Shortcut>jprop</Shortcut>
   <Description>Code snippet for property and backing field</Description>
   <Author>Peter G Jones (modified version of prop from Microsoft Corporation)</Author>
   <SnippetTypes>
    <SnippetType>Expansion</SnippetType>
   </SnippetTypes>
  </Header>
  <Snippet>
   <Declarations>
    <Literal>
     <ID>type</ID>
     <ToolTip>Property type</ToolTip>
     <Default>int</Default>
    </Literal>
    <Literal>
     <ID>property</ID>
     <ToolTip>Property name</ToolTip>
     <Default>MyProperty</Default>
    </Literal>
    <Literal>
     <ID>field</ID>
     <ToolTip>The variable backing this property</ToolTip>
     <Default>_myVar</Default>
    </Literal>
   </Declarations>
   <Code Language="csharp">
        <![CDATA[/// <summary>
  /// Backing variable for property $property$
  /// </summary>     
  private $type$ $field$;
  /// <summary>
  /// Property $property$
  /// </summary>
 public $type$ $property$
 {
  get { return $field$;}
  set { $field$ = value;}
 }
 $end$]]>
   </Code>
  </Snippet>
 </CodeSnippet>
</CodeSnippets>

I can see that creating more elaborate snippets is pretty easy.  I wonder if it would be possible to have CodeSmith snippets?  That would be really cool!

Tuesday, July 19, 2005 7:23:45 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   Visual Studio  | 
# Monday, July 18, 2005
Monday, July 18, 2005 3:40:21 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General  | 
# Friday, July 15, 2005
Nigel has got the TechEd session schedule up on the event site. 
Friday, July 15, 2005 12:04:32 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General  | 
# Tuesday, July 12, 2005

We recently had a minor incident with our visa cards - someone who shall remain nameless lost HER purse.  After much searching we decided to do the right thing and cancel our joint visa card.  Ten minutes after doing this, the purse rematerialised.  Joy.

Wev'e been waiting for nearly 2 weeks to get replacements (they are made about 2 minutes walk from where I work) and during that time Telecom tried to charge us.  It failed of course, becuase I don't have the new card number to give them.

Today, we had a call at home from an automated service.  It said to call 128.  Fair enough I guess, their staff must get a lot of abuse so why not have a machine do it. So, I dialled 128 and was given a choice of 5 different options, none of which matched my circumstances, so I picked 'you have been contacted by a collection agency'.  Then I was given another menu with 5 options - I can't remember what that was but I selected something close enough.  Then I had to select whether I was calling from the phone concerned or another phone.  I was calling from work so I selected option 2.  Then I had to enter my home phone number.  Then it wanted the last five digits of my account number - which I didn't have.  Phone home, get the lad to give me the number, repeat.  Got back to where I left off and enter the last 5 digits.  She says "That's Great!".  Yeah right.  But first, I need to enter a pin number.  Arrrrrrrrrgggggggg!!  Or select 0 to speak to a person.  Yay! Finally.

But here's the lovely part, the lady I finally got to speak with did not have my account details in front of her so all that time I wasted entering phone numbers & account numbers was completely pointless.

Grrrrrrr.

Tuesday, July 12, 2005 12:44:30 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   General  | 

Sean has posted about the new pricing of MSDN Universal in NZ.  A 48% price drop is pretty bloody fantastic! 

If you are in the unfortunate position of having to pay for this yourself - or you have to convince a penny pinching boss - then now is the best time ever to get MSDN.  I'd like to know the full retail value of all the software you get in MSDN (plus the free support!) - I'm guessing it's pushing $50k but it could be a lot more.  ~$3500 is a complete steal!

Tuesday, July 12, 2005 7:18:40 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General  | 

Darryl posted about an interview with Steve Balmer and the subsequent flood of slashdot abuse.

I watched the video.  It's nice to actually see Mr Balmer speaking - albeit for such a short interview. It's gratifying to witness his obvious devotion to developers.  It gave me a brief warm fuzzy feeling.

However, I also read some of the crap that slashdot posters said about his comments on open source and innovation.  There's no point to replying on slashdot, no point at all, so I'm doing it here.

Open Source is good. MS knows this.  They are a significant provider of open source code - just look at MSDN for a while, what about www.ASP.Net, www.GotDotNet.com, www.WinForms.net?  To say that MS doesn't understand or 'get it' is just plain silly.

From a business point of view, GPL and it's ilk are the devils spawn and stiffle innovation.  MS also knows this.  As a large (or small) company it would be extremely unwise to use any code that is covered by GPL.  For MS, this is a huge threat.  There are squillions of eager lawyers just waiting for the smallest infringement.

 

Tuesday, July 12, 2005 7:10:16 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General  | 
# Monday, July 04, 2005

I'm trying to format contents of a cell in a DataGridView using the following code:

private void RosterGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
  ShiftCell sc = e.Value as ShiftCell;
  if (sc != null && sc.RosteredShiftRow != null)
  {
   if (!sc.RosteredShiftRow.ShiftRow.IsForegroundColorNull())
     e.CellStyle.ForeColor = Color.FromArgb(sc.RosteredShiftRow.ShiftRow.ForegroundColor);
   if (!sc.RosteredShiftRow.ShiftRow.IsBackGroundColorNull())
     e.CellStyle.BackColor = Color.FromArgb(sc.RosteredShiftRow.ShiftRow.BackGroundColor);
   e.Value = sc.ToString();
   //e.FormattingApplied = true; // tried this and it make no diff
  }
}

This should set the current cell colours for some cells only.

However the result is crap:

Anyone got any ideas?

Update:  I fixed this by making sure I set the background colour to something valid.  Sometimes is was being set to 0 and other times it was not being set at all.  Now I either set both colours or none and it works really well. 

Monday, July 04, 2005 12:20:14 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   General | Visual Studio  | 
# Wednesday, June 29, 2005

I'm not normally one to blog on political, racial or religious issues, but some things are just too incredible to resist.  I refer of course to this:  http://news.bbc.co.uk/2/hi/americas/4631421.stm.  Ronald Regan was voted the Greatest American of all time.  The rest of the list of top 10 also looks decidedly dodgy.

This survey polled over 2 million citizens so you would like to think it's pretty representative - at least amongst Discovery Channel viewers and AOL users - so this is a huge worry.  Surely the intelligence level has not dropped so far?  Now I'm certainly no expert on American history but off the top of my head, I can think of one or two American's who I think are greater.  e.g. Henry Ford.

I wonder if New Zealand could come up with a better list or would it look something like this:

  1. Robert Muldoon
  2. Russell Crowe
  3. Sean Fitzpatrick
  4. Judy Bailey
  5. Micheal Campbell
  6. Lana Cocroft
  7. Edmund Hillary
  8. Tama Iti
  9. Neil Finn
  10. Gandi

 

 

Wednesday, June 29, 2005 2:06:44 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   General  | 
# Thursday, June 16, 2005

Rob Caron has posted that the June CTP of Team System is available for download.

I've got too much on at present to bother with this and we were also asked not to upgrade or patch past Beta 2 as part of some programs we are on with Microsoft.

I'd really like a new cut of Visual Studio though.  Some of the bugs drive me nuts.

Thursday, June 16, 2005 1:06:47 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   Team System | Visual Studio  | 

Wow!  My boss found this yesturday - I think it's a new feature in VS05 because I've never seen it before.  I'll be really annoyed if it's been in VS03 and I just never found it.

When you create a winform user control you normally need some container to test it in.  In the past I've always just done this as part of the larger application.  Now, when you have a control library project in VS, you can hit F5 and it will launch the UserControl Test Container:

Even better, you can load froms from any dll or exe:

Very cool!  This is a lot like the old ActiveX test container - but way nicer to use.

Thursday, June 16, 2005 9:16:21 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   Visual Studio  | 
# Friday, June 10, 2005
How to retrieve multiple results sets from a stored procedure into a dataset with a DataAdapter.
Friday, June 10, 2005 9:48:07 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   SQL | Visual Studio  | 
# Tuesday, June 07, 2005

Tim linked to a discussion on David Burkes blog about using Paul Wilson's O/R Mapper in a distributed environment.  In this, Paul said: 

"which in the end brings you back to the fact that distributed systems are not 'hard' but there are a lot of choices"

I certainly aggree that there are a lot of choices, but the only product I've found so far that is not hard is Alex's Base4 - which is not an O/R Mapper - but can be used to achieve the same result.

Maybe I need to have yet another look at Paul Wilson's mapper (which I will have to do soon for a small side project :) but my feeling is that if this was simple, I'd be doing it already.

I need to start working to my mantra - 'less is more, simple is better'.  To me O/R Mappers are a stop gap measure until somebody comes up with a real OO solution that provides all of the distributed functionality I require in an easy to use package.  So far, Base4 is the closest things I've found.  deKlarit is another option that I've used in the past and it does come a lot closer to the ideal solution for me, but again, it's not simple and requires a large time investment to learn.

Maybe this stuff is never going to be simple enough for me? 

Tuesday, June 07, 2005 9:29:40 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   General  | 
# Monday, May 30, 2005

I've been coding steadily for a couple of months now so I thought it was time for a few more favorites of VS05.

Refactoring
I tend to not use fancy tools like Resharper as I like a nice clean environment, even at the risk of getting OOS/RSI/CTS.  However, I find myself using the refactoring tool in VS 05 a lot more than I thought I would.  I particularly like the automatic method stubs it creates for you.  Also having it insert the namespace is very useful.  Both of these mean you don't lose your place in the code and can just continue on with the same train of thought.  I get easily distracted so this is a big boost for my productivity.  Things like rename, parameter delete, extract method are less useful at this point, but are more important features to have automated.

Snap Lines
I do a lot of win forms ui development - a lot more than I care to mention.  With snap lines, you can line up your controls horizontally and vertically in a simple visual way.  Very cool!  Don;t know why someone didn't think of this years ago.

Intellisence
Intellisence seems to be a lot more intelligent in VS05.  I can often enter several lines of code with very little typing.  When you type '.' the list of methods and properties is often positioned on the right item.  I think I type about 1/3 less than I do with VS03.

Source Control
The new team system source control is very fast and as far as I can tell, very secure and reliable.  The integration with VS is seamless and I'm not having nearly as many issues as I used to with VSS - it's seems a lot easier to create a source structure that matches your repository structure.  I haven't had the chance to use Shelving in anger yet, but I'm, sure it will be very useful when I need it.

The integration of work items into the checkin process is also very useful but I do find it awkward finding the correct work items in the list.  This is probably because of the way I work - which I think needs to change.

Data Sources & Data Binding
I know a lot of people hate data binding and it's a bit if a dirty subject, but I'm not afraid to confess that I use it.  I must admit though that it's not without it's problems at times.  Most of the issues I have had in the past (and some in the very recent past!) are due to a poor implementation in the tools or lack of understanding of how it works.

I think MS have got it right this time.  Setting up a data binding to a control is simply a matter of dragging a table or field from the data source window onto your form.  You can also bind to an existing control by dragging a field onto it.  You still need to write some code to attach the binding source to the actual data, but this is trivial.

If you don't like using data binding then just using the data source window to add controls to your forms will save you a lot of time.  Once you've dragged on your fields, just remove the binding source from the form and all the data binding will be removed with it.

Nullable types
I didn't think I'd use nullable types much, but it turns out I do.  I have created stored proc's that take int's and datetime values as parameters.  When I add a table to a dataset and specify the stored procs to use, VS05 automatically creates Fill & Get methods that have these parameters as nullable types.  Eg, the following stored proc:

   procedure GetEmployees
    @validdate datetime
   as
    select e.*
    from employee e
    where isnull(@valid_date, e.startdate) between e.startdate and e.enddate

VS05 will create an employeeTableAdapter with a Fill method thus:

   Fill(EmployeeDataSet ds, DateTime? validdate);

So I can call Fill(ds, DateTime.Now) to get all current employees or Fill(ds, null) to get all past and current employees.  No more need for DBNull!

Partial Classes
Partial classes make a lot of sence for win forms.  All of the designer generated code is in a separate file, making code changes a lot cleaner (and safer?).  However, I noticed that if you have an inherited form, you don't get a partial class - all the controls are included in the one form.

Monday, May 30, 2005 10:12:27 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   Visual Studio  | 

I've been making some changes to a small VB6 application recently. On the weekend I received the updated source from the customer, unzipped it and opened the project.  I tried to load the main form, frmMain.frm and bingo, VB6 crashed.

Hmmm, me thinks, that's weird, lets try that 15 more times and see if it still fails... yes, it does.  Lets try opening the last version of the source that used to work.  Hmmm... does the same thing.  Strange.  Backtrack.  What has changed?  I wonder if it was SP6 that I installed in between times?  Email customer, ask them to try.  Yes, works for them OK.  Crap.

So, I tried to remove SP6 and that didn't help.  In fact it made things worse.  I then tried to remove and reinstall VB6 and it got even worse!  Eventually, I managed to get VB to create a LOG file for the main form and it told me that MSCOMCTL.OCX could not be loaded.  Crap!  DLL hell!

To cut a long story short, I managed to get it all working again by installing the application from it's setup, which overwrote the stuffed DLL's/OCX's with the correct versions.  4 hours later I was working again.

All this got me wondering, why do some people still love VB6?  Have they simply forgotten how bad DLL hell was? Do they never use OCX's?  Do they never have to deploy these applications?

I must admit, that once it's working, VB6 is very quick to knock together a simple application and it's very easy to update other peoples code.  I particularly like that pressing F5 actually runs the application before I can make a coffee and iron a shirt!

However, 1 day of DLL hell is enough to convince me that I made the correct decision in choosing .Net.  Sure, it's more complex and I don't have to maintain or migrate large VB6 apps, but would you rather cruise down the motor way in a Model T or a BMW 7 Series?

Monday, May 30, 2005 9:11:18 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [2]   General  | 
# Thursday, May 26, 2005

I've switched to using BlogLines to read blogs.  It's an on-line web based service, similar to many others out there I suppose.  I couldn't tell you the pros and cons v similar sites but I can tell you that for me it's better than an offline windows reader.

Why?  Well, in no particular order, heres why:

1) I don't get bothered by it as often as I would with NewsGator or Sauce Reader etc
2) It works.  Sauce Reader has been beta for way too long.  I don't care that they had to rewrite the darn thing, others have managed to get working products in much less time.  NewsGator would be OK if I could get it to work at work.  I don't think it likes Outlook 02.
3) Bloglines has a downloadable windows notifier that you can set to check every minutes or day or whatever and it doesn't use googleplexes of ram.
4) I can have one single place with my subscriptions.  Previously I had to have the subscriptions on my work and home machine(s) and they were never in sync.  NewsGator offered a way around this with their on-line service but I didn't manage to get this working.
5) Bloglines is free and very easy to setup.  Plus you get a blog site there if you want it.
6) Bloglines has email subscriptions.


 

Thursday, May 26, 2005 2:01:15 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General  | 

SQL Reporting Services SP2 should be on MSDN Downloads by now.  Interstingly, it came through on the RSS feed dated May 24th but I coudn't find it in the download page yet.

SP2 includes a small number of useful patches and some new features.  I wouldn't call it a huge improvement, but it's worth the download.  Client side printing is probably the most useful feature.

Thursday, May 26, 2005 11:43:08 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General | SQL  | 

I normally wouldn't post about bugs in beta products (it's a beta after all) but this one is so annoying I thought people might like to know what I did to work around it.

Pre-beta 2 I noticed a rather annoying problem in Visual Studio 05 - some keys stop working.  Usually this is backspace, delete, undo, escape etc.  Everything but alpha keys.  It was very annoying!

So, I was a good chap and logged this on the product feedback site.  MS have recently responded and said that it will be fixed in a forthcoming CTP.  In the meantime,  I've been getting this a LOT recently and I was having to either restart VS.Net or reset the window layout - often 5 - 10 times a day.

The bug is caused by the tool windows (solution explorer etc).  You can usually get it to fault by pinning and un-pinning the solution explorer or properties window.

I found a better workaround.  Simply undock all the tool windows that live on the sides of VS and move these to your 2nd monitor.  Everyone has a second monitor right?  Well, if not, then you may not have room.  Since doing this a couple of days ago I have not had the problem.

Thursday, May 26, 2005 9:15:01 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   Visual Studio  | 

I whipped up (or is it ripped off?) a new skin last night.  If you reading this on the web page and not with an aggregator then this will be obvious.  I needed to do this so I could insert the Technorati link.  Tonight I'll also add in the Bloglines link.  These are required so as to register a blog with them.

You can clearly see I'm not web design guru but I must say that it's very easy to create a skin for dasBlog -  a lot easier than doing the same with .Text. 

I wish I'd discovered this a lot sooner as I would have done things differently.  My main site at jonesie.net.nz is still blank as I have been busy and I don't really know what to put there.  In hindsite, I should have just put this blog there and included the few extra things I need in the new skin.  I'll probably do this as my 3 regular readers probably won't get too upset with having to resub AGAIN.  Sorry...

 

Thursday, May 26, 2005 8:52:10 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [2]   General  | 
# Friday, May 20, 2005

I've been having a few problems with File based web projects (probably of my own making) so I switched to using HTTP (IIS) instead.  Unfortunately, this screwed my Team Build.

The solution is to manually edit the SLN file, as per the instructions here:  http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3968

This certainly fixed the immediate problem, now my tests are failing :{  Once I get these passing again I' should hopefully get a published build.  That will be a good achievement for a rainy Friday.

Friday, May 20, 2005 10:02:21 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [1]   Team System  | 
# Friday, May 06, 2005

Sean has blogged about TechEd 05 and I'd like to add my recommendation as well - BOOK NOW!  The early bird gets the you know what.  Judging by the session planning that Chuck has been doing, it's going to be extremely difficult to decide which session I'm going to miss.

Friday, May 06, 2005 10:07:32 PM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General  | 

I've noticed over the years that when a new version of a product is release (or close to release) I discover features of the old version that I didn't know about - and wish I had known about a long time ago!

I just found an article by Shawn Wildermuth that describes how to annotate dataset schema to alter the generated code.  This is not a new idea, the article is dated March 2003.  Well worth a read if you hate the way null values are treated - especially date fields.  Wish I had know about this in 2003 but I think it still applies to the new stuff.

 

Friday, May 06, 2005 8:47:32 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General  | 
Copyright © 2012 Peter G Jones. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: