mo.notono.us

Friday, May 28, 2004

Roland Weigelt - WinForms

Rolan Weigelt has a bunch of useful advice on Windows Forms. He's also about to contribute a nifty add-in to Roy Osherove's VS.NET add-in contest

SQL Server development techniques and sql scripts

Nigel Rivett has quite a collection of SQL Server development techniques and sql scripts. The sp_executeSQL tip came in handy when I had to build the following procedures:
----------------------------------------------------------------------------------------------------
--Created: Friday, May 28, 2004, by Oskar Austegard
--Purpose: Generic procedure to get the EditedTS for any given table and ID
----------------------------------------------------------------------------------------------------
ALTER  PROC ConcurrencyGetEditedTS 
	@TableName nvarchar(100),
	@IDName nvarchar(100),
	@ID int,
	@EditedTS datetime OUTPUT
AS
DECLARE @SQL nvarchar(250)
SET @SQL = N'SELECT @EditedTS = EditedTS FROM ' + @TableName
         + N' WHERE ' + @IDName + '=' + CONVERT(nvarchar(9), @ID)
EXEC sp_executesql @SQL, N'@EditedTS datetime OUTPUT', @EditedTS OUTPUT


----------------------------------------------------------------------------------------------------
--Created: Friday, May 28, 2004, by Oskar Austegard
--Purpose: Generic procedure to check for concurrency violation for any table and ID
----------------------------------------------------------------------------------------------------
ALTER   PROC ConcurrencyCheck
	@TableName nvarchar(100),
	@IDName nvarchar(100),
	@ID int,
	@EditedTS datetime
AS
DECLARE @ExistingTS datetime
EXEC ConcurrencyGetEditedTS @TableName, @IDName, @ID, @ExistingTS OUTPUT
IF @ExistingTS IS NULL
	RETURN -100
ELSE IF @ExistingTS <> @EditedTS
BEGIN
	RAISERROR ('The Edited Time Stamp for the %s record with %s=%d differs from that stored in the database.',
      16, 1, @TableName, @IDName, @ID)
	RETURN -999
END
RETURN @ID

Labels:

Wednesday, May 26, 2004

ReSharper Build 83

OK that was quick - Build 83

Labels: ,

Tuesday, May 25, 2004

ReSharper

Build 82 is out.
  • Tooltips shown when mouse is over symbol in code now contains doc-summary
  • Code formatter: options to add braces for if- and other statements with single statement body
  • Go to Usage: tooltips with code are shown when hovering mouse over the list
  • Introduce Variable refactoring is able to introduce constants
  • Lot of bugfixes
Now we just need some documentation...

Labels: ,

Monday, May 24, 2004

Updated C# V2.0 Specifications now available - take 2

How does the introduction of nullable versions of value types affect operations that previously required reference types because they might result in null? The as operator comes to mind - from the 2.0 specs: "20.8.6 The as operator The as operator can be used with a type parameter T as the right hand side only if T is known to be a reference type [see §20.7]. This restriction is required because the value null might be returned as a result of the operator. "

Updated C# V2.0 Specifications now available

Eric Gunnerson posts about the Updated C# V2.0 Specifications now available. One new entry is nullable types, with which I have some experience already, in the form of luKa's Nullable Types library. The C# 2.0 version looks very similar (essentially a structure with the underlying type plus a boolean HasValue denoting null status). Of course the MS approach is a little more streamlined - for example they add a new null coalescing operator, ?? which works exactly like the SQL ISNULL function. Can't wait to have typed datasets and other generated code based on nullable types...

Thursday, May 13, 2004

Google Copernicus is Hiring

More Google silliness. Yeah I know it's old.

DataSets vs. Custom Entity Objects

A couple of interesting blogs on a debate we've had at work as well: DataSets vs. Custom Entity Objects

Norway: Pros and cons

Ja, vi elsker dette landet: Norway: Pros and cons

Map24 - Cool new online mapping program

Well - it's new to me at least: Map24

ReSharper goes M2

Haven't installed build 81 yet, but I'm looking forward to edit my own Live Templates. Not to mention all the bug fixes.

Labels: ,

Swirl

I'm dizzy If only the subject was more appealing. El Dorko sitting next to his grandmother's bed - or what must otherwise be the worst looking couch ever - is not what I want to be staring at...

Wednesday, May 12, 2004

New Blogger Features + Comments Welcome

I like the new blogger features - but it's about time.  Features like comments, email posting, etc. were not available until now, and I promptly turned them on.  Will be interesting to see if I ever get any comments...  I'm sure Rob will post some anonymous crap... Update - well maybe he would if he could - I don't see any way to add comments yet... AT least I'm able to post by e-mail, though it takes a while to show up.

Boxing and ? : - Eric Gunnerson responds...

I wasn't content in just posting my annoyance - so I forwarded it to Eric Gunnerson, who actually replied (I don't know how he has the time - I hereby apologize to everyone for wasting his time and thereby contributing to .NET 2.0 being delayed):
"Oskar, "The compiler behavior is correct, though perhaps a bit surprising. "When the compiler is evaluting such an expression, it needs to determine the type of the expression. If the types are different, it does this by trying to convert between them, and if A can be converted to B, it chooses B as the type of the expression. "In your example, there is no such conversion, so you get the error message. "This is covered in section 7.12 of the language spec."
...and also in Section 14.12 of the ECMA C# Language Specification I promise I'll RTFM before wasting Eric's time next time I have a question...

Wednesday, May 05, 2004

Boxing and ? :

There is an inconsistency in C# that I find somewhat annoying: The following code will break:
int i = 0;
object o = (i == 0) ? null : i;
The error message is that "There is no implicit conversion between 'null' and 'int'." - as if we're trying to assign null to i, which of course we're not. The following works fine (of course):
int i = 0;
object o;
if (i == 0) 
  o = null;
else 
  o = i;
and also:
int i = 0;
object o = (i == 0) ? null : (object)i;
My problem isn't so much with the fact that the original code won't compile, but rather that the error message is simply wrong and misleading.

On Comment Rot

Eric Lippert has an interesting point about the misuse of comments: Aargh, Part Five: Comment Rot

Typed DataAdapters....

Sounds like my stored proc wrapper CodeSmith template will be unnecessary in Whidbey: Early Adopter: Tour of the VS2005 Data Experience Not that surprised, really.

Labels: ,

Tuesday, May 04, 2004

Gmail Request List

I want GMail, so I can get rid of my Yahoo account, so I can stop paying it and SBC money for something I used to get for free. Begging publicly is not beneath me: Channel9 Wiki: GmailRequestList

Labels:

Monday, May 03, 2004

More reasons for using Windows Forms today

After my last big web application project (in ASP.NET) I swore I would never do another big application in HTML. The pain of creating a decent UI was just too much. So our current project (in the ~4000 hr range) is written in Windows Forms. Convincing management to go with Windows Forms over ASP.NET was not entirely straightforward - this blog by Juval Lowy would have helped: The Road to Longhorn Goes Through Windows Forms