Monthly Archives: January 2012

@@ROWCOUNT is affected by IF statement

Let’s say you’re writing T-SQL code and need to make sure that your query returns one and only row. If no records returned – an error message needs to be shown. If more than one record is returned – another error message needs to be show. The code goes something like this:

-- ... query runs here and returns row

IF @@ROWCOUNT = 0 RAISERROR('No records found', 18, 1)
ELSE IF @@ROWCOUNT > 0 RAISERROR('More than one record found', 18, 1)

-- ... continue when exactly one row is returned

Now if your query returns 3 records you’d expect it to trip the second IF statement and raise error with correct message. Unfortunately this doesn’t happen. The reason being – the first IF statement resets @@ROWCOUNT to 0. So, to avoid this we need to preserve the @@ROWCOUNT value in a local variable:

DECLARE @iRowCount int

-- ... query runs here and returns row

SET @iRowCount = @@ROWCOUNT

IF @iRowCount = 0 RAISERROR('No records found', 18, 1)
ELSE IF @iRowCount > 0 RAISERROR('More than one record found', 18, 1)

-- ... continue when exactly one row is returned

This way count of rows returned by the query is saved and is not affected by any following statements.

UltraWebGrid TopItemSpacing=”Auto”: Solution for FireFox

If you’re still using classic Infragistics Controls and want to make them work in modern browsers, sometimes a little additional work is required. Hopefully this little trick will save you some time.

UltraWebGrid has a neat property TopItemSpacing, when set to Auto it automatically spreads top level menu items across the menu control, giving them nice spacing in between. Unfortunately this property seems to work in Internet Explorer only, in Firefox (and Chrome and etc.) it is ignored, rendering menu in Compact mode giving top level items crowded “too-close-for-comfort” look.

The solution is to take spacing in our own hands. Set TopItemSpacing to Compact and instead add right padding to TopLevelParentItemStyle and TopLevelLeafItemStyle elements of the menu. For example (from the markup point of view):

<TopLevelLeafItemStyle Cursor="Hand" Height="18px" BorderWidth="1px" Font-Size="8pt">
   <Padding Right="6px" />

Actual pixel value of the padding is up to your particular scenario, but the final result is top level menu items will be nicely spaced both in IE and in Firefox.

ICS: Android 4 on Kindle Fire

Ice Cream Sandwitch on Kindle Fire

Another day, another experiment on my new favorite toy business instrument – Kindle Fire. Today I went ahead and installed latest (as of this date) incarnation of Android OS – version 4 aka Ice Cream Sandwich (ICS). Again, like in case with CyanogenMod 7 (which is essentially Android 2.3.7) installation is extremally easy thanks to TWRP recovery. Just download Kindle Zone ICS ROM put it on your Fire, reboot into TWRP recovery, *backup your existing rom* and flash the ICS.

It boots nicely and looks pretty good. Connects to WiFi with Internet and LAN access (ES File Explorer comes preinstalled and accessed SMB shares on my home network with no problems).

Being a very early version it has it share of problems. Video doesn’t work correctly (MP4 files for example play in fast-forward mode, YouTube can’t connect). Sounds work sporadically and overall moving around the interface has a jerky feeling. But it looks like a very good start and I am looking forward to a more stable release. Meanwhile I am back to CM7

UPDATE 02/18/2012. Now this is what the doctor ordered. The new update from the same XDA forum thread as above breathed new life into my Kindle. Basically, everything works. And it looks awesome! Here is direct link to the ROM. So now this is my OS of choice for my Fire. Did I mention it’s Cyanogen Mod 9? Did I also mention that there’s Google Chrome now available on Android Marked for Ice Cream Sandwich?

Ice Cream Sandwich on Kindle Fire

WebDataGrid: Prevent scrolling on row selection

If you working with Infragistics Aikido controls and your WebDataGrid or WHDG is too long – a common approach to make content scrollable is to place grid control inside of a DIV with fixed dimensions and overflow set to auto:

WHDG scrollable inside of parent DIV

It works fine, but there’s one drawback: if you scroll your grid horizontally and then select a row – grid’s scroll position snaps back to the leftmost position. Infragistics says that it’s a browser bug and we need to talk to browser vendor about it. Wanting to solve the problem in this century I looked for alternatives and this is what I found. Continue reading →

CyanogenMod on Kindle Fire

CyanogenMod on Kindle Fire Lately I’ve been posting a lot about Kindle Fire and no wonder – I love this tablet and tweaking with it.

Today I went to tweaking extreme – installed a custom ROM, namely CyanogenMod. CyanogenMod is famous for being a better replacement ROM for a wide multitude of Android devices from Droid phones to Nook tablets. And finally it made its way to Kindle Fire. Installing it turned out to be surprisingly easy – first, using Kindle Fire Utility root your Fire and install TWRP Recovery – very useful instrument not only for installing new ROMs but also for backing up and restoring your existing one in case something goes wrong. Second, download latest CyanogenMod in form of “” and place into temp/download folder of your Fire. And lastly reboot into TWRP recovery, browse for the ZIP and install it.

CyanogenMod didn’t let down, it was perfect as usual – fast, highly customizable, this one specifically build for Fire with its lack of hardware buttons. It has many wonderful features (for example picture in this post is, unlike previous posts, is a direct screenshot from my Fire, “take a screenshot” is one of the options appearing in menu when you press and hold power button).

It has everything. The only drawback for me is, for the love of it, I couldn’t make Amazon Instant Video app work in this mod. The issue is widely discussed on the Interwebs, multiple possible solutions are offered, but none worked for me. And since Prime Instant Videos is the only original Fire feature that I use – I had to return back to rooted stock Amazon ROM with ADW launcher (thanks TWRP for making ROM backup and recovery a very simple experience). Until working version of Amazon Instant Video is bundled with Cyanogen – I am keeping the stock.
Continue reading →