Wednesday, May 14, 2008

Showing installed app versions with BgInfo

I love it when you can use one cool tool to enhance another cool tool.  Duncan Epping posted an English translation of a Arne Fokkema post about how to use BgInfo to display the version number of VMware Tools that has been installed inside a VMWare virtual machine.

If you have never used BgInfo, it's a great little utility written by Bryce Cogswell of Sysinternals fame.  BgInfo will write a desktop bitmap that will contain useful information about the machine: machine name, ip address, version stuff, free space, etc.  You can set BgInfo to run when you login by placing a shortcut to it in the user's or shared startup folder.

When you work with multiple servers, real or virtual, their desktops all tend to look alike.  BgInfo makes it easy to see at glance which machine you are currently connected to.

What Arne wrote about was that in addition to displaying predefined variable, BgInfo can display version information from any file that has version information.  You point BgInfo to the location of the VMWareServer executable and select version formation and you are done.  The screen shot from Arne's blog shows how simple it is:

BgInfo is very handy for displaying static information.  Since the desktop background is only being rendered when you login in, you wouldn't want to use it to display a dynamic variable, like CPU load.  I can see where you would use this to display other version type of information.  If you are testing against multiple service pack versions of SQL Server, you could display that information.   While I've been talking about using this for a VMware virtual image, this is handy for Virtual PC images or any server that you would remote in to.

Thursday, May 08, 2008

Uninstall IE8 Beta before installing XP SP3

If you running the beta version of Internet Explorer 8 (IE8) under Windows XP, the word is to uninstall IE8 before installing Windows XP Service Pack 3 (SP3).  Once SP3 has been installed, you will be unable to remove IE8 (and IE7).  The reason for this is documented on the IEBlog with this post.  Basically, when you install IE7 or IE8, the existing IE6 (version of IE that comes with XP) is backed up to an uninstall folder.  SP3 includes an updated set pf IE6 files.  If you were to uninstall IE7 or IE8 after installing SP3, you would have a mixture of IE6 files from pre-SP3 and the bits installed as part of SP3.  That would cause all sorts of problems and Microsoft disables the uninstall option for IE7 and IE8 after SP3 is installed.

Not being able to remove IE7 isn't a big issue.  If you have IE7 in place, the odds are that you are used to it and will not be removing it.  The beta version of IE8 is another situation altogether.  When the next beta or release candidate or even the actual release comes out, you'll want to uninstall the beta version first.  It's just the prudent thing to do.  Well not exactly, it's much safer to install anything labeled beta in a virtual machine.  But if you have the IE8 beta installed on a XP box and you are planning on installing SP3, you'll want to remove the beta before installing SP3.  In fact, Microsoft will not offer SP3 through Windows Update if it detects the IE8 beta on your machine.  Once SP3 has been installed, you can install the IE8 beta again.

Tuesday, May 06, 2008

Dealing with the Duplicate Resource: Type 24 when enabling theme support in Delphi 2007

I was writing a little utility in Delphi 2007 to make it easy to work with data stored as the XML data type in SQL Server. While I have been using Delphi 2007 since it was released last fall, this was the first desktop app that I had written from scratch. I threw some components up on the form and I did a quick compile to see how the visual elements looked at runtime. I got the following error message:

[DCC Error] E2161 Warning: Duplicate resource: Type 24 (user-defined), ID 1; File C:\dev\RawDataQuery\RawDataQuery.res resource kept; file c:\program files\codegear\rad studio\5.0\lib\WindowsXP.res resource discarded.

I was dragging and dropping components from an app that I had originally written in Delphi 7 and one of the components was a TXPManifest component. The TXPManifest is component that only appears at designtime. When your code is compiled, it includes the WindowsXP.res resource file, which contains the manifest resource needed to enable XP style themes. In Delphi 2007, you can enable theme support in the project options. It's a checkbox labeled "Enable runtime themes" on the Application page of the Project Options dialog.

You can't have both "Enable runtime themes" checked and an instance of TXPManifest in your application. They both try to pull in WindowsXP.res and the second attempt will FAIL. The fix for this is easy. You can disable the "Enable runtime themes" setting or remove the TXPManifest component from your form and remove the reference to xpman in that form's uses clause.

My personal preference is to remove the component and unit references and just use the project setting. When there are two methods of doing the same thing, I tend to pick the simpler solution. The fewer the number of moving parts, the less likely it is for something to break.

Monday, May 05, 2008

Identity hijacking on Twitter.

The other day, I got an email from Twitter announcing that someone new is following me.

SIOOMA! (Siooma) is now following your updates on Twitter.

Check out SIOOMA!'s profile here:

 http://twitter.com/Siooma

You may follow SIOOMA! as well by clicking on the "follow" button.

Best,
Twitter

If you are on Twitter, then you have seen that type of message before.  It means that a user with the handle "Siooma" is now following my site.  I took a peek at Siooma's Twitter page and sure enough it lists a Fake Steve Jobs blog post as the home page.  Siooma is one of the FSJ's favorite sayings, read that blog post for the full definition - I don't want to spoil the fun by taking it out of context.  I read some of Siooma's previous "tweet" and I don't think it's the real deal.  They were sort of FSJ-like, but they were missing the sharp edge that a real FSJ post would have.  Part of what makes FSJ so fun to read is how close to the truth he appears to get at.

If you do a search on Twitter for FSJ, you get a couple of hits.  None of them are the authentic FSJ.  His Twitter handle is FakeSteveTwit, which oddly enough doesn't come up in that Twitter search.  Doing a parody of a famous person can be entertaining, the "real" Fake Steve Jobs is both entertaining and informative.  He does more than a Mad Magazine style of parody, FSJ covers actual Apple events and applies the FSJ twist to the analysis.  The man behind the satire, Daniel Lyons, is a real journalist and does a good job covering the stock options backdating scandal that involved the real Steve Jobs a while back.  When you read FSJ, you wonder how to close he gets to the actual Steve Jobs and does the real Steve Jobs ever wish he could say some of things that the FSJ says.  None of the FSJ clones on Twitter have that magic.  Even if they could, it would hard to produce that in 140 character limit of a Twitter post.

Siooma is welcome to follow my Twitter feed, but I'm not planning on reciprocating.  FSJ has but some serious time and effort in his blog.  The FSJ wannabees are just riding on his coattails.  When they list his blog as their web site, it comes off that they are pretending to be the FSJ.  Lyons does not have a monopoly on being a fake Steve Jobs, but it's not right to claim his site as your own.  If Siooma and the other clones want to be another FSJ, then they should get their own FSJ blogs and develop their own personas.

Friday, May 02, 2008

How to rename database objects to comply with naming conventions

We have guidelines for the naming conventions of our database objects.  It's pretty much the common pattern you see all over the place. For example, we use the following convention for default constraints:

DF_TableName_ColumnName, such as DF_Student_School

Pinal Dave has great set of database coding standards on his site, more in-depth than ours actually.  We have found that using coding standards makes the database schema easier to read and makes it easier to perform schema updates.  If you don't explicitly name a default, SQL Server will name it for you.  And it wont be pretty or consistent across databases.  We have our own tool for pushing out schema updates to our customers and it assumes the object names will be the same for each database.

When we submit our schema updates internally, we usually catch any deviation from our naming conventions.  It's not a perfect process and every now and then, something slips through the cracks.  We then correct the schema update to use the appropriate naming convention.  if we have been using the schema changes internally, we may have some databases that don't match the published schema for the object names.  When that happens, we run a simple T-SQL script that cleans house.  The following T-SQL will scan the database for default constraints that do not match our naming conventions and rename the ones that it finds.

DECLARE @OldName nvarchar(512)
DECLARE @NewName nvarchar(512)
DECLARE @OldToNewName nvarchar(512)

-- We use a table variable to contain the list of objects to be renamed.
DECLARE @FixSchema TABLE(
sys_OldName [sysname] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
sys_NewName [sysname] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
)

-- Get the list of current column defaults
-- The OldName column represents the current name of the default
-- The NewName column represents the name of the default using
-- our naming convention
INSERT INTO @FixSchema(sys_OldName, sys_NewName)
select o.name AS OldName
,'DF_' + Object_Name(o.parent_obj) + '_' + c.Name AS NewName
FROM sysobjects o
JOIN syscolumns c ON o.parent_obj = c.id AND c.cdefault = o.id
WHERE o.type = 'D'

-- Declare cursor on this table variable to access on the non-compliant
-- constraints
DECLARE AddDrop CURSOR FOR
SELECT sys_OldName, sys_NewName
FROM @FixSchema
where sys_OldName <> sys_NewName

OPEN AddDrop

-- Loop through the list of defaults where the default name is not
-- strongly typed
FETCH NEXT
FROM AddDrop
INTO @OldName, @NewName

WHILE @@FETCH_STATUS = 0
BEGIN
-- Assenble a T-SQL command that can be executed dynamically
-- to rename the constraint
SELECT @OldToNewName = 'sp_rename ' + QUOTENAME(@OldName,'''') +
', ' + QUOTENAME(@NewName,'''') + ', ' + QUOTENAME('object','''')

-- Print the command to be executed. Useful for seeing
-- what is being done
PRINT @OldToNewName

-- Execute the T-SQL to rename the object. If the EXEC line is
-- commented out, the code will display what would be changed
-- with making any actual changes to the schema
EXEC(@OldToNewName)
FETCH NEXT
FROM AddDrop
INTO @OldName, @NewName
END

-- Close and deallocate the cursor
CLOSE AddDrop
DEALLOCATE AddDrop

I usually use the INFORMATION_SCHEMA views to peek at the table and column structures.  The INFORMATION_SCHEMA.COLUMNS view will tell which columns have default constraints, but not the name of the constraint. In this case I needed to access the sysobjects table to retrieve the name of the constraint.  The same type of code can be used to rename other objects like check constraints.

Wednesday, April 30, 2008

A more robust way of converting a string to an enumerated value (enum)

A while back, I had blogged about a tip that Mark Wagner had posted about converting a string to an enumerated value.  Tim Sneath posted a similar tip even earlier, except his had some additional error logging.  Tim's post made it to DotNetKicks, which is good because having the additional error handling is just good coding practice. 

enum Sushi
{
Ika,
Hirameh,
Tako
}

// ...
Sushi lunch = (Sushi) Enum.Parse(typeof(Colour), "Tako", true);
Console.WriteLine("Sushi Value: {0}", lunch.ToString());

// To avoid an ArgumentException for strings that do have
// corresponding enumerate values, call Enum.IsDefined()
// first.

string NotSushi = "pizza";

if (Enum.IsDefined(typeof(Sushi), NotSushi))
{
lunch = (Sushi) Enum.Parse(typeof(Sushi), NotSushi, true);
}
else
{
// Add your error logic here
}

Mucho gracias to Tim & Mark...

Troubleshooting SQL Server connectivity issues

Xinwei Hong (MSFT) wrote a great troubleshooting guide on how to identify and resolve SQL Server connectivity issues on the SQL Protocols blog.

Xinwei broke it down to 6 possible causes:

  1. Network issue.
  2. SQL Server configuration issue.
  3. Firewall issue.
  4. Client driver issue.
  5. Application configuration issue.
  6. Authentication and logon issue.

For each cause. Xinwei lists some background on why that cause could a problem along with specific commands to run to help diagnose the problem.  For example, to determine if #2, SQL Server configuration issue, is the root cause of the problem; the following steps are listed:

You need to make sure the target SQL Server is running and is listening on appropriate protocols. You can use SQL Server Configuration Manager (SCM) to enable protocols on the server machine. SQL Server supports Shared Memory, Named Pipes, and TCP protocols (and VIA which needs special hardware and is rarely used). For remote connection, NP and/or TCP protocols must be enabled. Once you enabled protocols in SCM, please make sure restart the SQL Server.

 

You can open errorlog file to see if the server is successfully listening on any of the protocol. The location of errorlog file is usually under:

%ProgramFile%Microsoft SQL Server/MSSQLxx.xxx/MSSQL/Log

If the target SQL instance is a named instance, you also need to make sure SQL Browser is running on the target machine. If you are not able to access the remote SQL Server, please ask your admin to make sure all these happen.

 

This guide is definitely worth keeping bookmarked.  When a client calls and they can't connect to their database, having a list like the one Xinwei provide should make it easy to resolve the problem.  Or at the very least, rule out the usual suspects.

Tuesday, April 29, 2008

I just installed the PowerCommands for Visual Studio 2008

I just installed the PowerCommands 1.1 for Visual Studio 2008.  This is a set of extensions to the VS 2008 IDE that provide some additional functionality.  The available commands are listed here.  The Collapse Projects command sounds pretty basic, but it's something I've always wanted and it's great for large solutions. 

The best part of PowerCommands?  You get the source code, which would be handy if you ever want to write your own VS extension.

My "Windows Feedback" copy of Office 2007 Ultimate just came in

I just received a NFR copy of Microsoft Office 2007 Ultimate in the mail.  Last December, I signed up for the 2008 Microsoft Windows Feedback Program Sweepstakes.  This was a three month program run out of the Windows Feedback Program.  As part of the program, I installed some software on one of my home PC's that recorded some basic metrics such as Windows settings, hardware details, how the common document folders are being used, changes to the system, and problems that may occur.

This information was sent back to Microsoft to provide information on how our PC was being used.  In return for allowing MS to collect this data for 3 months, I was given a choice of several different products from Microsoft (Vista Ultimate, Office Ultimate, Money Plus Premium, Encarta Premium, or Streets and Trips).  I opted for Office 2007 Ultimate.  I didn't need another copy of Office right now, but it would handy the next time I get a new machine.   Apparently the response to this offer was so huge that Microsoft closed the program to new entrants after only a day or so.

In addition to the monitoring software, I was required to answer at least one survey during that time period.  Oddly enough, I was only prompted once during the 3 month period to answer a survey.  At this point, I'm no longer obligated to run the monitoring software and I haven't decided whether or not to uninstall it.  I'm not a big fan of monitoring software, but I'm not seeing any performance impact and I'm satisfied with the privacy issues with the data being sent back.  I know some people roaming the series of tubes were calling this spyware, but technically the WFP software isn't spyware.  Most definitions of spware define it as software that collects data or controls a computer surreptitiously and was installed without informed concept.  I knew what it was doing and I opted in, which means it's not spyware.  At most, Microsoft now knows how much time my kids spend at Webkinz World.

It would be nice to see what data was being sent back to the mothership, but if MS is following their own Terms of Use for this program, my privacy concerns have been satisfied.  This is in strong contrast to a program launched by Sears Holding Corp (SHC). at roughly the same time, where they wanted to install some software that would be a lot closer to the definition of spyware.  The software that Sears wanted to install was a web proxy from ComScore (never identified as such by Sears) that would track all of your web usage and sent that data to Sears.

The software used by SHC is a web proxy program supplied by Comscore.  It redirects all of your web browser activity through the Comscore software and that data can be sent to Sears.  SHC notifies the user that the user is about to install some software, but it does not go into full detail about what data is being collected and what is being sent to Sears.  At no point during the installation process or preliminary email is the software identified or it's functionality  described.  A person with computer security experience would realize what is going on, but the average computer user would have no idea what they just installed.

With the security breaches on Sears web site earlier this year, I would be very hesitant with letting Sears have access to my personal information.  I understand why Sears would want to know what I shop for online, and I don't mind sharing that information.   Sears has no business knowing how I pay for those items and has no business viewing my email.  Comscore's tracking software would monitor all of that.  All privacy issues aside, that's a horribly inefficient means of tracking online shopping.

It also looks a little funny that the guy in charge of this program, Rob Harles, was a former senior vice president at Comscore.  Comscore is the vendor for the tracking software that the SHC wants to install. Ben Edelman, assistant professor at the Harvard Business School who focuses on spyware practices, did a great write up about the SHC sofware.  He documented in clear detail (with screenshots and video) that the installation steps violate FTC guidelines.  If you Google for Sears & spyware, you'll get close to a quarter of million hits.  That's not what you call good publicity, but I digress.  When I participate any sort of consumer feedback program, I take a close look at what would be installed and what will be collected.  I also check to make sure that the company collecting the data is collecting the right data and will respect my privacy.  Microsoft met those concerns.