SQL Code Highlighting in Visual Studio

This is something I’ve been trying to do for a while and finally found the solution in a forum post (. The post is very succinct so I’ll expand on it a little more here.

I am working with .SqlDataProvider files which are basically T-SQL scripts to create data tables, stored procedures and other db objects. When you open a file like this in Visual Studio, you get no syntax highlighting at all. There is an option to associate file extensions to editors within VS but none of them allow you to match an extension with the SQL editor. The only way to do this is by a little registry hack.

Here is how it’s done so you can repeat it for any other language type:

1. Open the registry editor (regedit.exe)
Note: if you don’t feel comfortable with editing the registry, I’d suggest that you stop right there and deal with the non-highlighted text

2. Go to
————Language Services
where version is the version number for your Visual Studio (8.0 for VS 2005 and 9.0 for VS 2008)

3. When you expand the Language Services key, you get a list of languages supported by VS. The one we are interested in is T-SQL90. Expand this key and copy the string value called (Default). For T-SQL90, the value is {43AF1158-FED5-432e-8E8F-23B6FD592857}

4. Now, go to
————File Extensions

5. Create a new key with the name of your extension including the dot. In our example the key name will be .sqldataprovider

6. In the newly created key, paste the value that we previously copied in the (Default) String Value. You can also define a name for the extension by creating a new String Value called Name and setting it to any name you want

You can now close the registry editor, restart your Visual Studio and voila, your SQL code is highlighted

Reference: Thank you Neolithos for this solution – http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/9187dc75-fc05-4872-bfc1-1fdbff590df2/


Infinite Loop with DotNetNuke 4.9

I have worked with Dot Net Nuke (DNN) several years back but I just started working again on the latest version so it’s almost like starting from scratch. It seems that a problem that happens on many DNN installations is the infinite loop bug. In IE this manifests itself by the page not loading while Firefox does present an error message saying that it is stuck in an infinite redirect loop.

There seems to be several known reasons for this behavior:
– trailing / in the alias name
– non default port used in IIS
– .NET AJAX having problems running in Medium Trust mode.

You can find the fixes for these problems in this post for example: http://www.bestwebsites.co.nz/dotnetnuke/solving-the-dotnetnuke-redirect-loop/

However, in my case, it had nothing to do with the above. I was just referencing the wrong cell in a datagrid causing an error which was for some unknown reason to me putting DNN in that infinite redirect loop state. This could have been caused by a bad install on my local machine but I kind of doubt it because it was a very basic install with nothing special.

I found the error by manually tracing the new code I created so I have no solution to track this down. I just wanted to mention it in case someone else has a similar issue to make sure you don’t get stuck on looking only at the 3 solutions presented all over DNN blogs.

Launching applications with a DOS batch file

This is not groundbreaking but hopefully this can help someone. In my case, I use a batch file to launch applications while my laptop boots up. This is useful because it takes a while for my corporate laptop to get up to speed as it launches an anti-virus, remote management client, firewall, etc… I do not want to add those applications to the Startup menu because sometimes I want to boot without launching them. The advantage of the batch file is that I have only one shortcut to click to launch multiple applications.

Anyway, the most important part of creating such a batch file is that you need to point to shortcuts and not the executable itself. The reason for this is that if you point to the executable, you will be stuck on the first application as it will not release the handle until the application is closed. Basically, it ties the command prompt to your application.

All you need to do is create a shortcut to the application which you can do by right-clicking on the executable and choosing “Create Shortcut” from the context menu. This will create a file with the .lnk extension. This is the file you want to target in your batch commands.

So, a batch file to launch, lets say, Outlook and Firefox could look like this if we moved the shortcuts to a startup folder on the C: drive:


You can save this text file with a .bat extension. You can now either create a shortcut to this file, or save it to your desktop for easy access.