Editing .SqlDataProvider scripts within Visual Studio
Location: BlogsBrian Dukes    
Posted by: Brian Dukes 10/13/2008 9:17 AM

I had finally had it.  I was no longer accepting the lack of tool support while editing the .SqlDataProvider scripts for DotNetNuke modules.  I needed to figure out a way to make Visual Studio treat those files as if they ended with .sql instead of .SqlDataProvider so that it would give me syntax highlighting for my SQL scripts.  Finally, I found an article about doing the same sort of thing for Torque files.  I don't have any idea what Torque is, but what I found there seemed to do the trick.

 NOTE: The below tip involves editing the registry.  No warranty is expressed or implied.  YMMV.

What I learned from the above linked article is that the file associations are controlled in the registry.  By simply adding a .sqldataprovider key to the correct location and giving it the same value as the .sql key, everything magically works as expected.

The key to create is HKLM:\SOFTWARE\Microsoft\VisualStudio\Languages\File Extensions\.sqldataprovider where version is 7.1 for Visual Studio .NET 2003, 8.0 for Visual Studio 2005, etc.  Those are the two versions I updated, so those are the two I'm sure of.  You should be able to find other versions without too much trouble.  If you're into PowerShell (I'm getting there), here are the four seperate commands to run in order to add this functionality to those two versions of Visual Studio.

For Visual Studio .NET 2003:

New-Item -Path 'HKLM:\SOFTWARE\Microsoft\VisualStudio\7.1\Languages\File Extensions\.sqldataprovider'
set-itemproperty -Path 'HKLM:\SOFTWARE\Microsoft\VisualStudio\7.1\Languages\File Extensions\.sqldataprovider' -name "(default)" -value "{A5C4C661-62BB-11D1-9CFD-0000F81E818C}"

 For Visual Studio 2005:

New-Item -Path 'HKLM:\SOFTWARE\Microsoft\VisualStudio\8.0\Languages\File Extensions\.sqldataprovider'
set-itemproperty -Path 'HKLM:\SOFTWARE\Microsoft\VisualStudio\8.0\Languages\File Extensions\.sqldataprovider' -name "(default)" -value "{FA6E5E79-C8EE-4D37-B79A-5067F8BD5630}"

**UPDATE** For Visual Studio 2008:

New-Item -Path 'HKLM:\SOFTWARE\Microsoft\VisualStudio\9.0\Languages\File Extensions\.sqldataprovider'
set-itemproperty -Path 'HKLM:\SOFTWARE\Microsoft\VisualStudio\9.0\Languages\File Extensions\.sqldataprovider' -name "(default)" -value "{FA6E5E79-C8EE-4D37-B79A-5067F8BD5630}"

Hope it helps!

Permalink |  Trackback

Comments (3)   Add Comment
Re: Editing .SqlDataProvider scripts within Visual Studio    By Allov on 10/13/2008 9:15 AM
Got the samething for VS 2008?

Re: Editing .SqlDataProvider scripts within Visual Studio    By dukesb11 on 10/13/2008 9:17 AM
Sure thing, Allov, I've updated the post.

Re: Editing .SqlDataProvider scripts within Visual Studio    By Nathan Rover on 11/10/2008 10:00 AM
Wonderful post, this was one of those kinda annoying things that I wish I had the time to try and figure out. Thanks.


Your name:
Title:
Comment:
Add Comment   Cancel