Sunday, June 01, 2008
Yes, LessThanDot is finaly live and kicking.

6/1/2008 10:39 AM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Monday, May 19, 2008
Me and some other people have been working on a brilliant new site it is called LessThanDot and it contains a wiki, blog and forums all accessible via a single login. Please visit us from the first of june onwards at http://www.lessthandot.com

5/19/2008 9:01 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Monday, April 28, 2008
On windows files can be locked by different programs. This little gem unlocks your file so that you can delete it.

4/28/2008 10:13 AM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, April 17, 2008
I found out yesterday that my sql server backups were corrupt and so I couldn't restore them (happy me). So I went out on Google and combined a few things to make this

declare @verifystatement nvarchar(250)
declare @backupdevice nvarchar(250)
declare @err int

set @backupdevice =     (SELECT     TOP 1 [physical_device_name]
            FROM     msdb.dbo.backupmediafamily backupmediafamily
                JOIN msdb.dbo.backupset backupset ON backupmediafamily.media_set_id = backupset.media_set_id
                and backupset.backup_start_date = (    SELECT max(backup_start_date)
                                    FROM msdb.dbo.backupset child
                                    WHERE child.database_name = backupset.database_name and child.type = 'D')
                and database_name = 'TexDatabase'
                and backupset.type = 'D')

set @verifystatement = 'restore verifyonly from disk = ''' + @backupdevice + ''''
exec sp_executesql @verifystatement
SELECT @err = @@error

if @err <> 0
        begin
            insert into utils.dbo.tbl_backupverify(BackupDevice,BackupStatus,BackupError, VerifyStatement)
            values (@backupdevice, 'Failed', @err, @verifystatement)
        end
        else
        begin
            insert into utils.dbo.tbl_backupverify(BackupDevice,BackupStatus)
            values (@backupdevice, 'Succes')
        end

Just put it in a Store procedure and run it as a job.


This is the tbl_BackupVerify create table statement.

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tbl_BackupVerify]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tbl_BackupVerify]
GO

CREATE TABLE [dbo].[tbl_BackupVerify] (
    [Id] [int] IDENTITY (1, 1) NOT NULL ,
    [BackupDevice] [nvarchar] (250) COLLATE Latin1_General_CI_AS NOT NULL ,
    [BackupStatus] [nvarchar] (50) COLLATE Latin1_General_CI_AS NOT NULL ,
    [VerifyDate] [datetime] NOT NULL ,
    [BackupError] [bigint] NULL ,
    [VerifyStatement] [nvarchar] (500) COLLATE Latin1_General_CI_AS NULL 
) ON [PRIMARY]
GO

You could add this as a scheduled job in sql-server.

Just don't forget to check the log table or make it send an email.



4/17/2008 2:00 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
SELECT *
FROM msdb.dbo.backupmediafamily backupmediafamily
JOIN msdb.dbo.backupset backupset ON backupmediafamily.media_set_id = backupset.media_set_id
and backupset.backup_start_date = (SELECT max(backup_start_date)
FROM msdb.dbo.backupset child
WHERE child.database_name = backupset.database_name and child.type = 'D')
and database_name = 'ReplaceWithDatabaseNameHere'
and backupset.type = 'D'


This is Based on something I found here. Thank you mrDenny.

And this works in SQL Server 2000.

4/17/2008 10:38 AM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Tuesday, April 15, 2008
So I also made the a similar template with structuremap support included.

Wich looks something like this

Imports Nunit.FrameWork
Imports StructureMap

Namespace $NAMESPACE$
    ''' <summary>
     ''' A TestClass
      ''' </summary>
       ''' <remarks></remarks>
     <TestFixture()> _
     Public Class $CLASSNAME$
    
#Region " Setup and TearDown "
        ''' <summary>
         ''' Sets up the Tests
          ''' </summary>
           ''' <remarks></remarks>
         <Setup()> _
          Public Sub Setup()
                       StructureMapConfiguration.UseDefaultStructureMapConfigFile = False
                   StructureMapConfiguration.ScanAssemblies.IncludeTheCallingAssembly()
            End Sub

        ''' <summary>
         ''' Tears down the test. Is executed after the Test is Completed
          ''' </summary>
           ''' <remarks></remarks>
         <TearDown()> _
          Public Sub TearDown()
                ObjectFactory.ResetDefaults()        
             End Sub      
#End Region     

#Region " Tests "
                   ''' <summary>
         ''' A Test
          ''' </summary>
           ''' <remarks></remarks>
             <Test()> _
              Public Sub $Test_Name$()
           
               End Sub
#End Region

     End Class
End Namespace
And of course I also made an XmlFile so you can easily import it.

NunitTestFixtureWithStructureMapSupport.xml (2,44 KB)
4/15/2008 2:52 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
I made a file template for resharper to make it eassier to create a TestClass

it looks like this.

Imports Nunit.FrameWork

Namespace $NAMESPACE$
    ''' <summary>
     ''' A TestClass
      ''' </summary>
       ''' <remarks></remarks>
     <TestFixture()> _
     Public Class $CLASSNAME$
    
#Region " Setup and TearDown "
        ''' <summary>
         ''' Sets up the Tests
          ''' </summary>
           ''' <remarks></remarks>
         <Setup()> _
          Public Sub Setup()
    
            End Sub

        ''' <summary>
         ''' Tears down the test. Is executed after the Test is Completed
          ''' </summary>
           ''' <remarks></remarks>
         <TearDown()> _
          Public Sub TearDown()
            
        End Sub      
#End Region     

#Region " Tests "
                   ''' <summary>
         ''' A Test
          ''' </summary>
           ''' <remarks></remarks>
             <Test()> _
              Public Sub $Test_Name$()
           
               End Sub
#End Region

     End Class
End Namespace
I also made an xmlFile so you can easily import it into Resharper.

NunitTestFixture.xml (2,15 KB)
.Net | Nunit | Resharper
4/15/2008 2:49 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Monday, April 14, 2008
Sometimes we just add references and never use them or use them and then remove it all again. And sometimes it is hard to say which reference we don't use anymore. Well MS has provided us with a button that looks up the unused references and if it finds ione you can remove the unused references.

So how do we do it.

First we right clikc on our project and select properties.



Then we go to the tab references and click on the button Unused References.




This will open a dialog with either a list of unused references (see below) or nothing in it.




And now you can just click remove and the references will be gone.


4/14/2008 1:48 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
Changing the targeted framework of a project in VB.NET 2008 with the Visual Studio IDE goes like this.

First we click right on the project name and choose properties.



Then we select the compile tab and click on the "Advanced Compile Options..." Button.



And last but not least we select the desired framework from the list "Target framework (all configurations)".





4/14/2008 1:32 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Sunday, April 13, 2008
Now that I have StructureMap and RhinoMocks in my stack I sometimes need to look for VB.Net examples of how to do things, because sometimes translating them from C# is not all that easy.

This article has helped me mocking events.

4/13/2008 11:05 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback