Sunday, February 17, 2008

MSSQL: The backup set holds a backup of a database other than the existing database.

When restoring a backup database that itself has a backup database, you will get this error:
"The backup set holds a backup of a database other than the existing '<DBName>' database."

All you need to do is to select the "Option" screen and make sure you have "overwrite existing database" selected.

Saturday, February 16, 2008

C# .NET: Get current dirctory of the executing process

System.Environment.CurrentDirectory doesn't always give you the current directory of the process. For windows service, it gives you C:\windows\system32.

Use:
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);