HOME | FERGUSON Digital Blog

Entries for month: May 2011

Horizontal Query Result

MS SQL2008 · By Michael Ferguson No Comments »

There are usually many different ways to obtain the same results. Not to mention the differences between several right ways and several wrong ways, but that's a post for another day. Consider the following query:

SELECT Record

FROM Table

WHERE RecordID = 1 OR

RecordID = 2

Results:


RECORD
----------
This
That

The table records a RecordID of 1 and 2 for two records named Record (bad names used for an example only) which contain this and that. When queried the results return two records. If you need to return these records in a special order, or parent/child association (RecordID 1 belongs to RecordID 2) you could also consider the following query which will name the two results as two different fields in one horizontal query row.

SELECT SubTable.Record AS SubRecord, Table.Record AS Record

FROM Table AS SubTable INNER JOIN

Table ON SubTable.RecordID = 1 AND Table.RecordID = 2

Results:

SUBRECORD RECORD
---------------------------
Thisᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠᅠ That

If you find this post useful please leave a comment and let me know how you used the information

Using a CSS Sprite as a CFTree Icon

ColdFusion · By Michael Ferguson 1 Comment »

I've been going through icon libraries on my websites and combining images into CSS Sprite libraries. The master image file, or sprite, holds all the individual images in it. You then call them out by coordinates in style statements instead of using an IMG tag. Why? Using a sprite instead of 20 images can save space, but I think the real advantage is the download.

When creating a GUI with many different icons, the visitor's connection may not be as good as yours, or the internet just hiccups and their browser tries to display your application but has a few empty IMG placeholders. If you were to use a sprite instead the visitor's browser only downloads one file and your style statements just call it over and over for the different coordinates.

The bad new is that the img attribute of the CFTREEITEM tag does not allow you to use sprites. Not to worry, there is a workaround. Instead of using the img attribute, put a floating span in the display attribute instead.

For example:

<cfset ImageIcon="<span style='margin: 1px; float: left; width: 32px; height: 32px; background: URL(SpriteIcon.png) -32px -32px;'></span>">

You may find a better method, but I had to float the sprite and the text to the left to get a good tree alignment. Also, I've chosen to make my icons 32 pixels square, which also made it easier to map the coordinates in the sprite.

<cfform>
   <cftree name="MyTree" format="html">
      <cftreeitem value="Test" display="#ImageIcon#<span style='float: left;'>test</span>" >
   </cftree>
</cfform>

Obviously this tree is more of a telephone pole, but I hope you get the idea. For a more useful CFTREE, build a query to populate your ColdFusion tree and map to different coordinates in your CSS sprite library image. The example above has only been tested with Internet Explorer 8.

For more information on how to create CSS Sprites, try an internet search for: "css sprites".

If you find this post useful please leave a comment and let me know how you used the information.

Internet Explorer Favorites are INI files

ColdFusion · By Michael Ferguson No Comments »

If you didn't already know, the favorites used by Internet Explorer are actually INI files.ᅠ I found this out, if I didn't know it previously and just forgot, when I was working on a file manager program and needed a way for Mozilla users to be able to read URL files uploaded by Internet Explorer users.

When I used CFDUMP to review the contents of an uploaded URL file, I found a perfectly formed INI layout that I could then use to redirect any browser to the intended website!

For example an Internet Explorer URL file to this site would look like this:

[DEFAULT]
BASEURL=http://fergusondigital.com/blog/
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
[InternetShortcut]
URL=http://fergusondigital.com/blog/
IDList=
IconFile=http://fergusondigital.com/favicon.ico
IconIndex=1

In a ColdFusion application, you can use GetProfileString and retrieve the value of InternetShortCut URL. Not sure this would be helpful anywhere else, other than to just read the contents of an Internet Explorer URL.ᅠ The contents of any URL can be read using Notepad.

If you find this post useful please leave a comment and let me know how you used the information.

© Copyright 1997-2024, All Rights Reserved Coldfusion and MS SQL2008
Powered by Mango Blog.   Design by FERGUSON Digital