10 January 2007

Visual Studio 2005 SP1, dotnetfx 3.0, LINQ => Refactoring gone

I installed Visual Studo 2005 SP1, dotnet 3.0, Visual Studio Code Name "Orcas" and LINQ.
When I wanted to use the refactoring the SmartTags stopped working and the Refactor option was missing!!!
I needed to refactor some .net 2.0 code and even nothing.
So I went googling and found the solution here!!!
Only the last option worked for me :)

The steps are:
1) Launch regedit.exe
Open HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Packages\{A066E284-DCAB-11D2-B551-00C04F68D4DB}\SatelliteDLL
Edit the "Path" value and change it from "C:\Program Files\Microsoft Visual Studio 8\VC#\VCSPackages\1033\" to "C:\Program Files\Microsoft Visual Studio 8\VC#\VCSPackages\"
Restart Visual Studio and see if these problems are fixed?

2) Open a command prompt, go to
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
Run
(i) devenv /setup
(ii) devenv /resetuserdata
(iii) devenv /resetsettings CSharp

When installing orcas / LINQ, be afraid, be very afraid.

02 January 2007

How to Pad Left a number?

Padding left a number using SQL Server is implemented using the REPLICATE TSQL function.
Here is an example to format a date:
DECLARE @Date VARCHAR(8)
SET @Date = CAST(YEAR(GETDATE()) AS VARCHAR(4))
SET @Date = @Date + REPLICATE('0', 2 - DATALENGTH(CAST(MONTH(GETDATE()) as VARCHAR))) + CAST(MONTH(GETDATE()) as VARCHAR) 
SET @Date = @Date + REPLICATE('0', 2 - DATALENGTH(CAST(DAY(GETDATE()) as VARCHAR))) + CAST(DAY(GETDATE()) as VARCHAR) 
SELECT @Date


Create a SQL Server function for padleft and padright and you job will be simplefied. Here is a good place to start.