February 2010 IT Toolbox – TechNet Magazine Online

February 19th, 2010

The February 2010 TechNet Magazine posts on the website. Check out my IT Toolbox column here:

February 2010 TechNet Magazine IT Toolbox

In this issue I covered:

  • Input Director: Control multiple Windows systems with one keyboard and mouse
  • IPNetInfo: Query multiple WHOIS servers on sets of IP addresses
  • QweryBuilder: Manage multiple database types through one interface

Check it out and let me know what you think!

And if you have a tool you want to see me review, please suggest it to me here: tntools@microsoft.com.

Shrinking your Transaction Log with SQL Server 2008 to Free Disk Space

February 5th, 2010

If you have been used to clearing up disk space on your development and test SQL server instance file systems with SQL Server 2000 or SQL Server 2005 by using the famous TRUNCATEONLY option on your transaction logs, you might be disheartened that they have removed this option from SQL Server 2008 (with good reason some might say).

If you do try to use it, you will get the infamous:

‘TRUNCATEONLY’ is not a recognized BACKUP option.

To achieve the same effect with SQL Server 2008, you can toggle the recovery mode for the target database and then call your DBCC SHRINKFILE to clear up disk space hogged by your transaction log.

USE MyDatabase
GO
ALTER DATABASE MyDatabase SET RECOVERY SIMPLE
GO
DBCC SHRINKFILE('MyDatabase_log',1)
GO
ALTER DATABASE MyDatabase SET RECOVERY FULL
GO

(Of course if you are already using simple recovery, you wouldn’t need to toggle.)

Hope this helps!

Don’t get caught by ANSI PADDING, VARCHAR, and trailing whitespace!

January 28th, 2010

One thing to be aware of when you have VARCHAR columns and are using ANSI PADDING: trailing whitespace is trimmed and not counted in your equality ( = / <> / LIKE) statements, so you might not get the results you are looking to be returned from your query.

In the same vein, the len() function will return the same value for two strings if one has trailing whitespace.  If you need to compare those two fields including trailing whitespace values, use datalength() instead.

Here’s some example T-SQL:

DECLARE @TABLE TABLE (FIELD VARCHAR(50))

INSERT @TABLE VALUES ('some text')
INSERT @TABLE VALUES ('some text       ')
INSERT @TABLE VALUES ('    some text')

-- returns 2 :
-- trailing spaces trimmed,
-- leading spaces count
SELECT '"' + FIELD + '"'
FROM @TABLE
WHERE FIELD = 'some text'

-- also returns 2
SELECT '"' + FIELD + '"'
FROM @TABLE
WHERE FIELD LIKE 'some text'

-- shows the difference between len()
-- and datalength()
SELECT FIELD, LEN(FIELD) AS 'Length', DATALENGTH(FIELD) AS 'DataLength'
FROM @TABLE

Hope this helps!

December 2009 IT Toolbox for TechNet Magazine

December 8th, 2009

The December 2009 TechNet Magazine is on the website. Check out my IT Toolbox column here:

December 2009 TechNet Magazine IT Toolbox

In this issue I covered:

  • Eraser: Eradicate Sensitive Information
  • SQL Server Backup Pro from Red Gate: Streamline SQL Server Backups
  • MindManager: Map Out Ideas, Notes and Projects

Check it out and let me know what you think!

And if you have a tool you want to see me review, please suggest it to me here: tntools@microsoft.com.

November 2009 IT Toolbox Column for TechNet Magazine

November 5th, 2009

The November 2009 issue of TechNet Magazine is out on the website. Check out my IT Toolbox column here:

November 2009 TechNet Magazine IT Toolbox

In this issue I covered:

  • BeyondCompare 3: Compare, Merge And Synchronize Files And Folders
  • WhatIsMyIp.com: Get IP Details; Test Connection Speed
  • ADRecycleBin: Find and Restore Deleted AD Objects

Check it out and let me know what you think!

And if you have a tool you want to see me review, please suggest it to me here: tntools@microsoft.com.

Also, as some of you know, this was the last print issue of TechNet Magazine. :(

But the digital edition will continue, so read on I say, read on! :)

Retrieve Image from Windows Clipboard via .Net C#

November 2nd, 2009

If you want to snag clipboard data from a different application into the context of your running .Net application, here’s how you can do it:

private static Image _clipBoardImage = null;

private static Image GetImageFromCopyPasteBuffer()
{
Thread t = new Thread(new ThreadStart(GetClipboardBitmap));
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
return _clipBoardImage;
}

private static void GetClipboardBitmap()
{
IDataObject data = Clipboard.GetDataObject();
if (data == null || !data.GetDataPresent(DataFormats.Bitmap, true))
throw new ApplicationException("No clipboard image data was present.");
_clipBoardImage = (Image)data.GetData(DataFormats.Bitmap);
}

Hope this helps!

.Net Friend Assemblies

October 21st, 2009

Have you ever want to create a “friend” assembly while programming with the .Net framework?  They can be very useful for segmenting your codebase amongst different projects.

Friend Assemblies allow an assembly to see the internal methods and properties of a different assembly by specifying an attribute on the primary assembly that specifies the assembly name of the friend.

The simplest way to do this is to add something like the following to your AssemblyInfo.cs file in your primary project:

[assembly: InternalsVisibleTo("my.friend.assembly")]

This would allow my.friend.assembly to have access to all of the primary project’s internals.

If you need to worry about security of the assemblies (I suppose we all should), then you should also consider using strong names in conjunction with the compiler attribute.

More information on .Net Friend Assemblies can be found here:

http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx

Hope this helps!

October 2009 IT Toolbox Column for TechNet Magazine

September 25th, 2009

The October 2009 issue of TechNet Magazine is out on the website. Check out my IT Toolbox column here:

October 2009 TechNet Magazine IT Toolbox

In this issue I covered:

  • AxCrypt: Secure Sensative Information
  • KaVoom! KVM: Software-based KVM Switch
  • (Book) Malware Forensics: Investigating and Analyzing Malicious Code
  • filext.com: Extension Discovery Site

Check it out and let me know what you think!

And if you have a tool you want to see me review, please suggest it to me here: tntools@microsoft.com.

Apache/Subversion: SSL negotiation failed: SSL error: parse tlsext

September 25th, 2009

If you are getting an error like the following when you do a large import or commit to Subversion over SSL:

Error: MKCOL of  
‘/repository/!svn/wrk/{GUID}/project/trunk/folder/file.ext’
SSL negotiation failed: SSL error: parse tlsext (https://mysite.com)


try modifying your Apache server’s httpd.conf, changing the SSLProtocol line like this:


#SSLProtocol -ALL +SSLv3 +TLSv1
SSLProtocol -ALL +SSLv3

Of course this will only work if you don’t need TLSv1 :)

(I ran into this while running Subversion 1.6.5 over Apache 2.2.13 on Windows 2003 Server)

 

Hope this helps!

Binding Apache and IIS both to Port 80 on Different IPs / Same NIC

September 25th, 2009

If you need to run IIS 6.0 and Apache 2.2.* side-by-side on the same Windows server machine, you most likely are trying to bind apache to one IP address and IIS to another.  If you have multiple IPs bound to the same NIC, this will only work if you do some tweaking to IIS’s metabase via httpcfg.exe

The httpcfg utility is found on the installation CD in the Suppot/Tools directory in the Support.cab file (you can use WinRAR or the like to extract it).

Once you have httpcfg on your system, you force IIS to bind only to specified IP addresses with a command like:

httpcfg set iplisten -i xxx.xxx.x.x

Here’s the KB that shows in detail you how to get it done:

http://support.microsoft.com/kb/813368/EN-US/

Hope this helps!