2013-10-31

Debug Classic ASP in Visual Studio

Note: This was tested in VS2010 and IIS 7.5.

In IIS:
  • Set up Classic ASP website in IIS.
  • Set Classic ASP application to allow ASP debugging:
    • Click on application
    • Double-click IIS/ASP
    • Open Debugging Properties
    • Enable Server-side Debugging = True
    • Click Apply
In Visual Studio:
  • Add breakpoints in server-side code of Classic ASP.
  • Start debugging:
    • Debug Menu/Attach to Process/Available Processes
    • Select w3wp.exe
    • Click Attach

2013-10-16

HashSet to Comma Delimited String

HashSet Coding Example: A HashSet is a collection that contains no duplicate elements.

Note: Tested in .NET 4.0.

       HashSet<string> myHashSet = new HashSet<string>();
       myHashSet.Add("A");
       myHashSet.Add("B");
       myHashSet.Add("B");
       myHashSet.Add("B");
       myHashSet.Add("B");
       myHashSet.Add("X");
       myHashSet.Add("Z");
       myHashSet.Add("B");
       myHashSet.Add("A");
       string commaDelimitedString = String.Join<string>(",", myHashSet);
       // commaDelimitedString is equal to "A,B,X,Z"

References
"HashSet(T) Class (System.Collections.Generic)." MSDN – the Microsoft Developer Network. N.p., n.d. Web. 16 Oct. 2013. <http://msdn.microsoft.com/en-us/library/bb359438(v=vs.100).aspx>.

2013-10-04

SQL Server Management Studio Settings

Miscellaneous, useful settings in SSMS.

Note: This was tested in SSMS 2012.

Assign custom colors to database servers. These colors are used on the status bar.
  1. Connect to Server
  2. Options >>
  3. Connection Properties tab
  4. Use custom color:

Change what is displayed in Tab Text (Example: Remove text that is redundant with status bar.)
  1. Tools/Options/Text Editor/Editor Tab and Status Bar/Tab Text
  2. Include database name (False)
  3. Include file name (True)
  4. Include login name (False)
  5. Include server name (False)

Copy column headers with query results
  1. Tools/Options/Query Results/SQL Server/Results to Grid
  2. Check "Include column headers when copying or saving the results"

2013-09-30

Customize Context Menu of SSMS

Problem
Need to customize context menus (also known as shortcut menus) in SQL Server Management Studio.

Solution

Note: This was tested in SSMS 2012.

Use the same technique that is used for Visual Studio. See Customize Context Menu of Visual Studio | CSC - Technical Notes for detailed instructions.

2013-09-24

Copy Page Title and URL to Clipboard

Bookmarklet to copy page title and URL to clipboard in Internet Explorer

JavaScript:window.clipboardData.setData("Text",document.title + "\r\n" + location.href);void(0);

Drag this bookmarklet to the bookmarks bar: JavaScript:window.clipboardData.setData("Text",document.title + "\r\n" + location.href);void(0);

Bookmarklet to copy page title and URL to prompt window for copying to clipboard in Chrome

JavaScript:window.prompt("Copy page title and URL",document.title + "\r\n" + location.href);void(0);

Drag this bookmarklet to the bookmarks bar: JavaScript:window.prompt("Copy page title and URL",document.title + "\r\n" + location.href);void(0);

2013-09-20

FULL OUTER JOIN Not Working

Problem

FULL OUTER JOIN not returning all records from right table when left table has a Search Condition in the WHERE clause.

-- Full outer join with where clause at bottom
-- Returns all records from MyTable1 where Category is 23.
-- Does not return all records from MyTable2. Only matches with MyTable1.
SELECT t1.[Code],t2.[Code]
FROM [MyTable1] t1
FULL OUTER JOIN [MyTable2] t2
      ON t2.[Code] = t1.[Code]
WHERE t1.[Category] = 23

Solution

Use a Derived Table for the left table. The Search Condition is moved from the WHERE clause to the Derived Table query.

-- Full outer join with derived table, no where clause at bottom
-- Returns all records from MyTable1 where Category is 23.
-- Returns all records from MyTable2.
SELECT t1.[Code],t2.[Code]
FROM ( SELECT * FROM [MyTable1] WHERE [Category] = 23 ) t1
FULL OUTER JOIN [MyTable2] t2
      ON t2.[Code] = t1.[Code]

References

See also SQL Join Types

2013-08-16

Team Foundation Server Delete Workspace

Problem

When a new developer uses a computer that another developer used, you may see the error: The working folder is already in use by the workspace on computer

Solution
  1. Make sure there are no pending changes for that user:
    tf status /user:username
  2. Delete the old workspace:
    tf workspace /delete [/server:servername] workspacename[;workspaceowner]

References

"Workspace Command." MSDN – the Microsoft Developer Network. N.p., n.d. Web. 16 Aug. 2013.
<http://msdn.microsoft.com/en-us/library/y901w7se(v=vs.90).aspx>.