Entries Tagged as 'Tips and Tricks'

Microsoft TSQL and the GO Statement

Gotchas , SQL , Tips and Tricks No Comments »

Recently I was working on some SQL scripts using TSQL in SQL Server Management Studio and from force of habit I was using the "GO" statement between each of my SQL statements to seperate them.

I then started re-factoring the SQL, creating variables where I had hardcoded values etc. and placed those variable declarations at the top of the script.

After re-factoring, I executed the scipt and got an error message saying that the variable @varName was not defined? 

I checked for any typos...none.  I then started breaking down the script to see if I could isolate the issue.  When I removed the "GO" statements, the script executed without error.

It turns out that "GO" is not a TSQL statement, but rather a command that is recognised by the sqlcmd and osql utilities and SQL Server Management Studio.  These utilities interpret the "GO" statement as a signal that it should send the current batch of TSQL statements to an instance of SQL Server.  Therefore any variables declared before the last "GO" and the next will NOT be available in the current batch of statements. 

Just for fun I then copied my TSQL into a <cfquery> and when I executed this, found that the same error was thrown.

One to watch out for if you're not familiar with the true definition of the "GO" statement. 

Full details of the "GO" statement can be found here: http://msdn.microsoft.com/en-US/library/ms188037(v=SQL.90).aspx


Bookmark and Share

HTML format CFGRID column data alignment

ColdFusion , CSS , Javascript , Tips and Tricks No Comments »

I came across an issue yesterday where I wanted to control the alignment of certain columns in an HTML data grid using the ColfFusion \ ExtJS CFGRID.  At first I tried the "dataalign" and "headeralign" attributes of CFGRIDCOLUMN but after checking the docs it turns out that these are only available with grid formats applet \ flash.

Without delving into the ExtJS docs, I found a really simple method of doing this without having to write one line of Javascript.

<style type="text/css">
    .x-grid-col {text-align:right;}
    .x-grid-col-0 {text-align:left;}
    .x-grid-col-1 {text-align:left;}
</style>

 You can also update just the column headers using a similar method. 

<style type="text/css">
    .x-grid-hd {text-align:center;}       
    .x-grid-hd-0-0 {text-align:left;}      
    .x-grid-hd-0-1 {text-align:left;}
</style>

Credit goes to the following post http://www.webtrenches.com/post.cfm/quick-and-easy-column-alignment-for-cfgrid by @spraguey

Thanks!

Bookmark and Share

Source-less Deployment of Coldfusion

Best Practices , ColdFusion , Tips and Tricks No Comments »

When deploying applications to any 3rd party hosting provider or client, you may wish to consider protecting your development effort and intellectual properties (IP) by either encrypting or pre-compiling the application code.

In the attached document, I will briefly cover a number of ways in which you can accomplish this.

There are currently three methods of deploying your ColdFusion applications in an encrypted format, which ship with ColdFusion, so as to help protect your code:

   1. Encrypting templates using the “cfencode” utility.
   2. Pre-compiling and deploying templates as Java Byte code using the “cfcompile” utility.
   3. Deployment Packages as J2EE Archives (EAR or WAR files) – accomplished using the ColdFusion Administrator.

Another option is packaging your application in ColdFusion Archive Files (CAR), but this is not within the scope of this document as there is no compilation or encryption used with this method.

Further details can be found at: http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=deploying_3.html

The above options all have their own behaviours, pros and cons.  These are discussed in more detail below.

The document can be downloaded from here.

If anyone has anything to add, please feel free to contact me or comment below.

 

Bookmark and Share

DZone and ColdFusion Portal Links

Online Resources , Tips and Tricks No Comments »

I came across these before but thought I'd share them out as they're pretty handy resources: DZone Check out the Cheatsheets too at RefCardz. There's one on getting started with ColdFusion 9.  

For ColdFusion, check out ColdFusion Portal.

Bookmark and Share

Possible Solution to Debugging & Testing in IE

AJAX , Browser Compatability , Javascript , Misc , Online Resources , Testing , Tips and Tricks No Comments »

Everyone knows how much of a pain it is to debug and test stuff in IE - especially for cross browser compatability and JS/AJAX errors or callbacks.

For development purposes - the following company provide a few nice solutions that could help with developing web applications in a number of versions of Internet Explorer.

DebugBar DebugBar: Is a toolbar which offers HTML DOM Tree view, HTTP and HTTPS Headers, page cookies view, HTML validation, JS Methods view, JS Execution etc. for Internet Explorer.

Companion.JS Companion.JS: Javascript debugger for IE - with detailed error reporting, Firebug like console logging, Javascript object inspection - enough said.

Last but not least...

IETester IETester: Allows for the rendering of web pages using the rendering and Javascript engines of IE5.5, IE6, IE7 and IE8 on Windows and Vista.

These are probably worth checking out as a solution to aid development and testing within Internet Explorer.

 

Bookmark and Share
Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds