Tuesday 26 August 2008

Creating custom item/project templates in Visual Studio

I found this post explaining how to create custom templates in visual studio 2005.

The process is quite simple.

Once you have a form, class or whatever you want to create a template for select 'Export Template' from the file menu.

There are various steps to follow and the option of creating a Project or Item template.

Wednesday 20 August 2008

Missing Visual Studio Project Templates

Works for both 2005 and 2008.

To rebuild visual studio project templates:

Open the Visual Studio Command Prompt and run the following:

devenv /installvstemplates

Thursday 14 August 2008

Backpack - Project organization

Backpack

Organize your business and share information with your team.

To-dos, Announcements, Ideas, Files
Easily centralize & share information across your organization

Keep a Group Calendar Online
Keep everyone's schedule online with a color-coded calendar

Have a look at the homepage, it would be good when were in a project because you can share files, notes and a calander and see what everyone else is up to!!

Thursday 7 August 2008

Set a DateTimePicker to Blank

If you have ever had problems setting the text of a datetimepicker to blank (rather than the default value) then the following code example is the way to do it:

if (csMahService._EndDate.HasValue)
{
dtpEndDate.Value = csMahService._EndDate.Value;
}
else
{
dtpEndDate.CustomFormat = " ";
}

Note you have to set the Format property to Custom.

Wednesday 6 August 2008

Format uppercase strings in SQL

Hi,

A useful SQL function here. It was written for SQL Server 2000, but I'm sure it can be adapted for any other SQL technologies.

It takes a string and changes it to be uppercase for the first char of every word and lower for the rest of it. E.g. "SQL IS GREAT FUN" becomes "Sql Is Great Fun".

Not much else to say... here it is!

CREATE FUNCTION dbo.ReturnFormattedString(@IN_String varchar(1000))
RETURNS varchar(1000) AS
BEGIN

DECLARE
@NewValue VarChar(1000)
, @X int
, @NewWord bit


SET @x = 1

SET @NewWord = 1

SET @NewValue = ''
WHILE (@x <= Len(@IN_String))
BEGIN

If (@NewWord = 1) and (
(ASCII(SUBSTRING(@IN_String, @x, 1)) >= 97) and (ASCII(SUBSTRING(@IN_String, @x, 1)) <= 122)
OR (ASCII(SUBSTRING(@IN_String, @x, 1)) >= 65) and (ASCII(SUBSTRING(@IN_String, @x, 1)) <= 90)
)
begin

if (ASCII(SUBSTRING(@IN_String, @x, 1)) >= 97) and (ASCII(SUBSTRING(@IN_String, @x, 1)) <= 122)
SET @NewValue = @NewValue + Char(ASCII(SUBSTRING(@IN_String, @x, 1))-32)
else
SET @NewValue = @NewValue + SUBSTRING(@IN_String, @x, 1)

SET @NewWord = 0
end
else
begin
if (ASCII(SUBSTRING(@IN_String, @x, 1)) >= 65) and (ASCII(SUBSTRING(@IN_String, @x, 1)) <= 90)
SET @NewValue = @NewValue + Char(ASCII(SUBSTRING(@IN_String, @x, 1))+32)
else
SET @NewValue = @NewValue + SUBSTRING(@IN_String, @x, 1)
end



SET @x = @x + 1


if Not
(
(ASCII(SUBSTRING(@IN_String, @x, 1)) >= 97) and (ASCII(SUBSTRING(@IN_String, @x, 1)) <= 122)
OR (ASCII(SUBSTRING(@IN_String, @x, 1)) >= 65) and (ASCII(SUBSTRING(@IN_String, @x, 1)) <= 90)
)
SET @NewWord = 1
END

RETURN(@NewValue)

END

Monday 4 August 2008

Windows installer - Remove Previous Versions

http://www.simple-talk.com/dotnet/visual-studio/updates-to-setup-projects/

Excellent link and explains how to unisintall previous versions of your application.

Note that the version number in the article refers to the installer version number that is accessed in the properties window. This must also being at 1.0.0 or above, otherwise the RemovePreviousVersions property won't pick it up as a previous version and won't work.

Enjoy!

SQL code to Enable/Disable a Trigger

Useful code to disable and enable a trigger:



ALTER TABLE YourTable DISABLE TRIGGER ALL
and
ALTER TABLE YourTable ENABLE TRIGGER ALL
Free Hit Counter