Simon Green's Developer Blog
Developing .NET in the cold white north ...

NAnt task for Red-Gate SQL Compare

Sunday, 7 May 2006 16:47 by Simon

One of the aims of Continuous Integration is to always have a releasable version of a project ready. For the code itself this is no problem but if the project includes a database with schema changes then it can be a little more complicated, especially if you have several versions of an application that are supported. You need a way of creating database change scripts for each version of the database as part of the build process.

Red-Gate make an excellent product called SQL Compare which can compare two database versions and produce a script to convert one version to the other and a SQL Toolkit that allows you to automate the process. They had a link to a NAnt task on their site but I found this a little inflexible so I created the one below which gives more control over what is compared and also allows you to set various SQL Compare options.

The main feature are that you can compare the current development SQL Server database against other databases and / or database snapshots with script generated to convert to and from each version. You can also save a database snapshot which can be put back into source control (as can the change scripts).

Here is an example of the configuration:

<?xml version="1.0"?>
<project name="comparesql" default="comparesql" basedir=".">
 <loadtasks assembly="C:\Program Files\nantsql-0.85-rc3\bin\NAnt.SqlTasks.dll" />


 <!-- target .NET framework and corresponding compiler directives -->
 <property name="nant.settings.currentframework" value="net-1.1"/>


 <target name="comparesql">
  <sql-compare
   folder="c:\output"
   title="TRUNK"
   server="DEVSERVER"
   database="AppDb"
   uid="dbuser"
   pwd="dbpassword"
   snapshotFilename="trunk.snp"
   scriptFilename="trunk.sql"
   saveScript="true"
   saveSnapshot="true">
   <objects>
    <object type="Field"/>
    <object type="Function"/>
    <object type="Index"/>
    <object type="Rule"/>
    <object type="StoredProcedure"/>
    <object type="Table"/>
    <object type="Trigger"/>
    <object type="UserDefinedType"/>
    <object type="View"/>
   </objects>
   <options>
    <option type="IncludeDependencies"/>
    <option type="IgnoreFullTextIndexing"/>
    <option type="IgnoreUserProperties"/>
    <option type="IgnoreUsers"/>
    <option type="IgnoreOwners"/>
    <option type="IgnorePermissions"/>
    <option type="TargetIsPreYukon"/>
   </options>
   <databases>
    <database
     title="BRANCH100"
     server="DEVSERVER"
     database="AppDb"
     uid="dbuser"
     pwd="dbpassword"
     snapshotFilename="BRANCH100.snp"
     scriptFilename="BRANCH100.sql"
     saveSnapshot="true"
     saveScript="true"/>
    <database
     title="BRANCH115"
     server="DEVSERVER"
     database="AppDb"
     uid="dbuser"
     pwd="dbpassword"
     snapshotFilename="BRANCH115.snp"
     scriptFilename="BRANCH115.sql"
     saveSnapshot="true"
     saveScript="true"/>
   </databases>
  </sql-compare>  
 </target>
</project>

I will post the source code on the main InteSoft.NET site for download.

 

Currently rated 2.5 by 2 people

  • Currently 2.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:   ,
Categories:   .NET | Build
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

"Bad Request" error when using friendly URLs with special characters in ASP.NET

Sunday, 7 May 2006 16:45 by Simon

Our ASPRedirector.NET product can be used to re-write query-string URLs to friendly URLs with ID parameters converted to text. This is typically done for Search Engine Optimisation to improve page ranking because words appearing in the URL are taken into account by search engines. We have developed re-writing configuration rules for many eCommerce / shopping-cart software packages such as BV Software's BVCommerce and MediaChase's eFC.

However, if the category and / or product name contain certain reserved characters then you can run into a problem. Even if the characters such as $. %, ? are encoded correctly the page may not be returned and all you see is "bad request" (error 400). It isn't URLScan that is causing this though but the behavior of the ASP.NET ISAPI filter which doesn't pass the request on.

There is a Microsoft KB Article 826437 about the issue

The solution given is incorrect though and the correct registry key entry is shown below:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET]
  "VerificationCompatibility"=dword:00000001

This fixes the issue and allows you to have nice, optimised URLs on your eCommerce website - regardless of the characters in you category and product names.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:   , ,
Categories:   .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed