Blog

Most Recent Blog Entries

Dec 3

Written by: Brian Dukes
12/3/2008 11:50 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\[version]\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}"

**UPDATE** I just upgraded to Vista x64, and the registry path changed a bit (as found in a comment to a similar blog post).  I think the change is because of x64, rather than Vista, though if you're on some other x64 OS, you might want to double-check before making this change.  That said:

For Visual Studio 2008 on Vista x64:

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

 

Hope it helps!

Tags:

1 comment(s) so far...

Re: Editing .SqlDataProvider scripts within Visual Studio

Needed this at work for some SQL files we save with different extensions. To do this in a .reg file, use this instead:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Languages\File Extensions\.sqldataprovider]
@="{FA6E5E79-C8EE-4D37-B79A-5067F8BD5630}"

That's for 2008, adjust correspondingly for other VS versions. Thanks for the tip!

By Matt Schuette on   8/27/2009 10:43 AM

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 

Purchase

Please click here to buy now.
Payment will be processed via credit card or PayPal.

Test Drive!

Want to find out how it works? Visit our demo site to see the modules in actions!

Subscribe

Sign up for our newsletter and get the latest product updates!

Online Support

Powered by DotNetNuke