Monthly Archives: June 2013

SQL Server – script to backup all SQL Server databases

DECLARE @name VARCHAR(50) -- database name  
DECLARE @path VARCHAR(256) -- path for backup files  
DECLARE @fileName VARCHAR(256) -- filename for backup  
DECLARE @fileDate VARCHAR(20) -- used for file name

 
-- specify database backup directory
SET @path = 'C:\Backup\'  

 
-- specify filename format
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) 

 
DECLARE db_cursor CURSOR FOR  
SELECT name 
FROM master.dbo.sysdatabases 
WHERE name NOT IN ('master','model','msdb','tempdb')  -- exclude these databases

 
OPEN db_cursor   
FETCH NEXT FROM db_cursor INTO @name   

 
WHILE @@FETCH_STATUS = 0   
BEGIN   
       SET @fileName = @path + @name + '_' + @fileDate + '.BAK'  
       BACKUP DATABASE @name TO DISK = @fileName  

 
       FETCH NEXT FROM db_cursor INTO @name   
END   

 
CLOSE db_cursor   
DEALLOCATE db_cursor

source: MSSQLTips

Visual Studio – The project type is not supported by this installation

Check ‘ProjectTypeGuids’ in .csproj file, to see which project type (GUID) may not be supported.
In my case I had MVC3 installed with Visual Studio Express. Later I got Visual Studio Ultimate and MVC3 was not supported by default. Installing MVC3 once again solved the problem.

Helpful sources:
Stack Overflow – GUIDS
SharePoint Space – edit GUID values
Dev Help – Project Type GUIDs

MVC 3 Set CSS class based on controller name

<%
//Response.Write(ViewContext.RouteData.GetRequiredString("controller"));
string currentController = ViewContext.RouteData.GetRequiredString("controller");
string activeClass = "background-color: #fff";

//....
%>
<ul id="menu">
	<li><a href="<%=Url.Content("~/")%>" <% if(ViewContext.RouteData.GetRequiredString("controller") == "Home") {%>style="background-color: #fff;" <% } %>> Home</a></li>
	<li><%: Html.ActionLink("Profile", "Index", new { controller = "Profile", action = "Index", id = -1 }, new { style = currentController == "Profile" ? activeClass : string.Empty })%></li>
	<li><%: Html.ActionLink("Reports", "Index", new { controller = "Reports", action = "Index", id = -1 }, new { style = currentController == "Reports" ? activeClass : string.Empty })%></li>
	<li><%: Html.ActionLink("Contact", "Index", new { controller = "Contact", action = "Index", id = -1 }, new { style = currentController == "Contact" ? activeClass : string.Empty })%></li>
</ul>