I came across a precarious situation today at work. I needed to write a paging stored procedure for use with a DetailsView. The situation and solution for start to finish is described at http://microsoft.apress.com/index.php?id=51. Unfortunately the sql database was currently running on an instance of sql 2000. Row_Number() is a specific function avaliable with sql 2005, not sql 2000.
The sql query I developed seems to work for an equivalent to Row_Number(). My case only had one sorting method, and I know that my column that is being sorted is unique. thus simplifying some matters.
Let's presume we have a Table1 with columns ID as an int, Code as a varchar, and Name. Table1 should be sorted by the column Code.
SELECT ID, Code, Name
(SELECT COUNT(ID) AS Expr1
FROM Table1
WHERE (Code < (SELECT Code FROM Table1 WHERE (ID = t.ID)))
) AS RowNum FROM Table1 AS t ORDER BY Code
Whilst this may not be very efficient or pretty, it gets the job done. Basically this query has a sub query to count the number of rows that are less than the current Code (which is selected by a further sub query).
Unorthodox probably, as bad as a GOTO statement maybe, works under the right circumstances.
Thursday, August 14, 2008
Wednesday, August 13, 2008
Viewing the details
Frustrations I came about using DetailsView for asp.net that are obvious but can be overlooked.
For custom Next/Previous/First/Last buttons:
CommandName="Page" CommandArgument="..."
[Command arguments paramters]
Yes the buttons need to be in a template of the DetailsView control, they cannot be outside. Make sure they aren't outside if they aren't working....grrrr.
To access an item in the Pager template:
DetailsView1.BottomPagerRow.FindControl("...")
In the aspx page, set the DataKeyNames to allow SQL Statements to be updated/deleted.
Cheers,
For custom Next/Previous/First/Last buttons:
CommandName="Page" CommandArgument="..."
[Command arguments paramters]
Yes the buttons need to be in a template of the DetailsView control, they cannot be outside. Make sure they aren't outside if they aren't working....grrrr.
To access an item in the Pager template:
DetailsView1.BottomPagerRow.FindControl("...")
In the aspx page, set the DataKeyNames to allow SQL Statements to be updated/deleted.
Cheers,
Tuesday, August 12, 2008
For each string cheese in package
Classic lines actually used in a program for a computer science class:
1.
foreach (string cheese in the_package)
2.
in_mouth.Push(one_cheese);
3.
/// the answer is in the pop (not the soda)
/// aka not in_mouth.Soda()
return in_mouth.Pop();
Quite possibly Nerd Levels of 4 (Nerd Levels)
1.
foreach (string cheese in the_package)
2.
in_mouth.Push(one_cheese);
3.
/// the answer is in the pop (not the soda)
/// aka not in_mouth.Soda()
return in_mouth.Pop();
Quite possibly Nerd Levels of 4 (Nerd Levels)
Friday, August 08, 2008
not funny
A comedian tells a joke to a crowd, people will laugh if the joke is funny, people will laugh if other people are laughing, or people won't laugh because the joke was not funny.
A comedian tells a joke to an individual, the person will laugh because the joke is funny, the person will not laugh because they do not understand the joke, or the person will not laugh because the joke was not funny.
Social conformity.
A comedian tells a joke to an individual, the person will laugh because the joke is funny, the person will not laugh because they do not understand the joke, or the person will not laugh because the joke was not funny.
Social conformity.
Sunny After Sunset
According to weather.com, tonight after the sunsets the weather will still be sunny out. Intriguing...

Cheers,
Oh and next time you go in for surgery, make sure your surgeon plays a wii.
(http://arstechnica.com/news.ars/post/20080808-wii-will-develop-surgical-skills.html)

Cheers,
Oh and next time you go in for surgery, make sure your surgeon plays a wii.
(http://arstechnica.com/news.ars/post/20080808-wii-will-develop-surgical-skills.html)
Thursday, August 07, 2008
The Hard Style
I've been listening to the Hardstyle and Happy hardcore channels during work these past few weeks. At about 8 hours of music, say 3 minutes a song, that roughly 160ish different songs. Unlike regular fm radio stations where I would hear maybe 20 different songs in 8 hours. Some how the music seems to drive me.
Fog is when the dew point is just below the temperature. Hopefully tonight will offer some glimmering stars.
Fog is when the dew point is just below the temperature. Hopefully tonight will offer some glimmering stars.
Monday, August 04, 2008
Pace of life
I always wish life would slow down, but I always tend to find myself making life busier and busier. My ability to plan underestimates the time/commitment/etc... of the activities. A day full of biking and exploring, a night full of stargazing wonders, somehow even that would find a way to get busy.
piece and cheers
piece and cheers
Subscribe to:
Posts (Atom)