Tracy’s Blog

Take your work seriously…but never yourself.

More Fun with XML (and SQL Server 2005)

Standing on SHoulder There is simply nothing more fulfilling and gratifying in the world of software development than solving a tough problem with an elegant, robust and scaleable solution.

Welllll…exxxxcept for googling your problem, standing on the shoulders of other programming geniuses, and using their elegant, robust, and scaleable solutions to solve your own tough problem. Programmers are inherently lazy and I’m no exception. So when I stumbled onto this little URL gem describing an elegant, scaleable, robust and plug-n-play-like method to providing a dynamic and variable number of parameters to a SQL stored procedure; I thought I’d share it with my fellow engineers.

Passing Lists to SQL Server 2005 with XML parameters.

[FYI; you must have Sql Server 2005 or greater].

Advertisements

December 12, 2007 Posted by | Tech | Leave a comment

The GridView’s GREAT From Up Here!!

ViewI recently found myself frolicking in the land of .NET 2.0 SqlDataSources and editable GridViews. After reading numerous excerpts touting the flexibility and ease with which web developers can now achieve virtually Excel-like interfaces between users and their data, I was stoked to try it all out.

In retrospect, I will certainly award snaps to those MS peepz for their notable effort towards predicting and facilitating the common-place task of giving web application users discriminating access to database stored information. I can only imagine the daunting task of attempting to allow for all derivations of developers’ preferences (Lord knows we’re opinionated if nothing else) while at the same time maintaining a minimal level of Integrated Development Environment complexity in order to achieve some element of intuition.

That said, I had a bit of trouble getting my (basic) editable GridView to work utilizing VS’s all-encompassing, plug ‘n play, SqlDataSource functionality. The predominant factor in my troubles were the subtle differences with which VS handles defining one’s SqlDataSource select/update functions via referencing stored procedures versus defining them with embedding SQL statements directly within Visual Studio’s SqlDataSource configuration wizard.

I’m happy to report that after a good night’s sleep and some professional help, however, I worked my way through the cryptic behavior and resolved all the issues. Here are the ‘GOTCHAS’ I encountered, in the hopes of alleviating [some of] a fellow developer’s trauma while exploring the wide world of editable GridView’s.

Behavior #1: No errors being generated and no exceptions being thrown, but the GridView’s update function just doesn’t do anything. I encountered this problem when the condition within my Update stored procedure was not being met [WHERE MAIN_ID = @MAIN_ID]. Unfortunately the reason(s) the condition was failing weren’t obvious.

  • Reason #1: As stupid as I feel admitting this, I’m going to do it for the sake of others who could be making a similar error. I wasn’t including the MAIN_ID field within my GridView’s select query. VS did not generate any type of error in spite of the fact that I was declaring a parameter named @MAIN_ID within my Update function that was not included as part of my GridView’s select query, but maybe that’s so they can allow for extraneous GridView column additions. At any rate, my ‘where’ condition failed in this case (obviously!) since it likely had a value of ‘NULL’ for the @MAIN_ID input parameter value.
  • Reason #2: If you’re referencing a stored procedure for your GridView’s select query, you’re likely missing the necessary DataKeyNames attribute value within your GridView element. At a minimum, this attribute needs to hold the name of the field(s) you’re using within the where clause of your update statement (in my case, I need DataKeyNames=”MAIN_ID”). From what I can tell, VS will auto-populate this attribute if you’re embedding the SQL directly within its SqlDataSource wizard with the names of any primary key columns it encounters, but no such auto-population will occur, nor will any errors/exceptions be generated when you’re referencing your own stored procedure.

Behavior #2: A ‘Procedure or function [your procedure’s name here] has too many arguments specified.’ exception gets thrown when you attempt to update a record within the Gridview.

  • Another dissimilar behavior characteristic between using embedding SQL versus a referenced stored procedure is VS’s ability to automatically determine the fields that should be included as parameters within the GridView’s update statement. When using embedded SQL, the update parameters will be automatically limited to those elements included within your SqlDataSource’s element regardless of the number of BoundFields you have listed within your GridView. However, when referencing a stored procedure every BoundField that does not contain a ReadOnly attribute value of ‘True’ (and BTW it’s default value is ‘False’) will be included as a parameter and sent to your stored procedure REGARDLESS of what you have listed as . This seems highly un-intuitive to me, too, but it’s an easy fix once you know that’s what’s going on. You can either change each of the BoundFields that you don’t want included as update parameters to have a ReadOnly attribute value of ‘true’ or you can go ahead an include their column names as input parameters within your stored procedure (@CURRENT_STATUS_DESCRIPTION) and just do nothing with them.

As a sidenote, here are a couple of incorrect/outdated solutions I encountered on other forums and wasted time pursuing:

  • Solution #1: The = comparison issue. One forum claimed that if you were including nullable columns within your GridView and attempted to update a column with a current value of NULL, the GridView’s update procedure would attempt a = comparison, which would return false and halt the execution. I found no such behavior in my .NET 2.0 Framework and SQL Server 2000 configuration.
  • Solution #2: Anything to do with the value contained within SqlDataSource’s ConflictDetection attribute. After wasting time on this one, I wound up using the default value (easily achievable by just omitting the attribute altogether) and everything’s working just fine.
  • Solution #3: Anything to do with the value contained within SqlDataSource’s OldValuesParameterFormatString attribute. [See solution #2].

Other than that, Mrs. Lincoln…how was the play?

December 12, 2007 Posted by | Tech | 1 Comment

Sssssleep Tight

ASC Stinger

The ASC Stinger; Fast, strong, gorgeous, and built on the 2005 GTO chasse…I think I’m in love.

The ASC Stinger car has inspired me to make my car into even more of a sleeper than it already is. It used to bother me; the lack of reverence and awareness paid to my car in spite of its impressive, corvette-engine performance specs. Unlike its much sexier, inferior performing, counterparts, only the occasional, true motor-heads stop to take another look at my vehicle, or listen for the throaty growl of 400 horses when I roll by. So I’ve come to a conclusion; why fight it?

As such, my automobile will be undergoing a few subtle, yet effective exterior modifications to further conceal its origins and remarkable performance capabilities – making it an even more severe sleeper:

A JHP lip spoiler replacement
18″ wheels (something with a thick 5 spoke chrome look)
A Skip Shift Disabler
All-Around Badge Removal
A Gauge Pod

Christmas Wish List:
Short Shifter (Not sure what they were thinking when they gave the GTO a shift throw that’s a mile long. This little device would probably shave half a second off my quarter mile time. ^_^)

GTO

December 12, 2007 Posted by | Carz | Leave a comment

Managing the Management

I had a brief stint as a retail manager. By brief, I mean about a year and a half. It was, without a doubt, the most anxiety-filled overwhelming task I’ve ever participated in, but I learned more about myself and others in that short time than probably any other period in my life. I learned things that can’t be taught in a book; things like good confrontation skills, and the delicate balance between being fair and just without getting walked all over. At the peak of my store’s season, I was wholly responsible for 28 employees, not to mention the merchandising and sales of 2 high volume departments. To complicate matters, I was all of 19 years old at the time (one of the youngest area sales managers in the company) and all but 2 of my associates were senior to me.

Looking back now, I’m not entirely sure how I survived. I remember many an afternoon/evening/morning sitting, crying at my tiny desk in the corner of my tiny stockroom after shrieked at, cussed out, and insulted by an irate customer (or even an associate). But much like vacations in Rocky Point, you have to experience hell to really appreciate heaven.

In spite of the routine compliments paid me by my district and store manager about my managing ability, I had little faith in myself at the time. It wasn’t until later in life; after being managed by a series of less-than-adequate managers in various positions myself, that I realized how good my associates really had it. They were the real reason I stayed in that hell-job as long as I did. I loved my associates, well most of them. But the ones you love, those are the ones you get up in the morning for (or in my case just never go home and spend the night). Nothing in that godforsaken store came anywhere near watching someone actually enjoy their underpaid, overworked position just because you were able to create a pleasant working environment for them doing things they loved.

I had a wonderful mentor (ironically, in the one career I haven’t pursued). Her name was Astrid Tuholski. She is German and was my first manager when I began my short career as a department store clothing salesperson. She was brilliant, everything I knew to do as a manger was just from watching her interact with her associates. She always knew exactly what to do to make her good associates love their job and make her bad ones hate it, all the while appearing completely professional and appropriate.

Here’s some of what I learned from her:

  • Make your associate(s) your number one priority; before merchandise, deadlines, goals, even bosses; if they’re happy everything else will fall into place.
  • Be a buffer for your associate(s), it’s your job to get yelled at by irate customers, co-worker’s or annoying bosses; not theirs.
  • Be an example for your associate(s) to follow.
  • Never expect an associate to do something you’re not willing to do yourself.
  • Never expect as much out of your associate(s) as you do yourself, that’s why you get paid more than them (hopefully).
  • Be very selective and hesitant when fraternizing with associates (better yet, just avoid it altogether).
  • Confrontation is part of the job so get over your fear of it (or learn how to fake it well) otherwise you WILL NOT make a very good manager.

December 12, 2007 Posted by | MISC | Leave a comment

I Smell Ice Cream

DiningIt seems that virtually every week I discover a new, ecclectic, character-filled, cheap, yummy place to eat in this culinary mecca of a city. I’ve been a resident now for a little over a year and here are my personal picks in order of preference for cheapest, yummiest, funnest places to grab a bite;

  1. Sushi Deli II [Downtown] – This place has, by far, the best and most inexpensive sushi rolls I’ve ever tasted. And their atmosphere filled with loud 80’s pop music and $5.50 large Sapporo/Sake special makes for a good time had by all.
  2. The Turf Club [Golden Hill] – This cook-your-own steak dive bar comes complete with $6 sirloins and $6 16oz (potent) drinks.
  3. Cass Street Bar and Grill [Pacific Beach] – Who knew a bar could have such delicious, fresh food (even their breakfasts!) and the informality of it all means more than reasonable prices.
  4. Hash House a-go-go [Hillcrest] – Every inch of the walls in this place are covered with awards and notariety for their food and presentation, and they’ve earned every bit of it.
  5. Luigi’s Pizza [Golden Hill] – Amaaaaazing Chicago-style pizza and an impressive selection of bottled beers. (Though I suggest purchasing a pie at a time @ a reasonable $20.00 each rather than by-the-slice since their individual slices are occasionally fly-friendly.)
  6. Ichiban Sushi [Pacific Beach] – Sushi Deli II’s rolls are far superior, but for reasonable, yummy, sashimi, I head here. It’s a tiny place, but well worth the wait.
  7. Hodad’s Burgers [Ocean Beach] – A health nut’s nemesis; GIANT burgers, HUGE fry wedges, and lots of beer.
  8. Rusty’s [Crown Point] – A close second behind Hodad’s; good burgers, good beer, good times.
  9. Filippi’s Pizza Grotto [Pacific Beach] – Deep dish, cheap, yumminess.
  10. CafĂ© Zucchero [Little Italy] – Amazing, authentic Italian food.
  11. Celadon [Hillcrest] – Not the cheapest place, but if you’re into Thai food; it’s the best I’ve had in the city and the atmosphere is quite pleasant.
  12. Extraordinary Desserts – One word: wow.

What did I miss?

December 12, 2007 Posted by | MISC | Leave a comment

WANTED: Career Mentor; Apply Within.

MentorI’ve never had a mentor, well, I guess that’s not entirely true. I’ve never had a software developer career mentor. When I made the decision to be a veterinary scientist (maaaany years ago), it was ‘cuz I was the girl who rushed the dove with the broken back who had flown into a nearby window, or the baby quail who was the runt of the flock and had been left behind wandering back and forth along a tall city curb, to the nearest wildlife facility.

I had always felt a strong sense of empathy and a deep connection with animals (well, mammels and birds at least), so a life of healing and helping animals just seemed a natural course. But as you likely know, life often has other plans in store for us.

Two months into my college career (and a case of mono later), I was no longer a college student and spent the next 3 years of my life as a full-time retail associate and manager. That brief exposure was plenty to make me realize a college education was well worth my time, money, and effort for the monetary and occupational rewards. Once again, lacking direction from a career mentor I developed a simple formula for determining which bachelor’s degree to pursue upon my return to college:

< Industry Demand + < Monetary Potential + > Education Time = Computer Science

Note the lack of

< Career Enjoyment/Fulfillment

and

> Education Difficulty

within my formula. I’m grateful for my lack of consideration regarding the latter since I’ve realized that in spite of being a prisoner of the computer lab for nearly 4 years of my life, it’s a worthwhile pursuit for obtaining a strong foothold within such a lucrative industry.

With regard to the first missing formula component, I often wonder if my anti high-school career counselor approach to vocational searching will eventually and ultimately lead to my burnout, but again, without a mentor to weigh my decisions against, I went the “I’ll enjoy anything that challenges me” route rather than the, “I must pursue a career I’m already naturally interested and gifted in” route.

So here I sit; at another junction in my career where I could really use a little influence from someone who’s had to make a similar decision, has pursued a similar career path, and has been exposed to the industry long enough to have insights and premonitions that I cannot.

No, wait…scratch that; I think I just found the perfect mentor: Google.

December 12, 2007 Posted by | MISC | 1 Comment

B-E-A-utiful!!

sd.jpg

It’s days like today that remind why I pay exorbitant (make that ‘hideously inflated’) rent to live here. I recently acquired the task of performing audits on a handful of secret systems we have located on the Campus I work at; what relevance does this fact have to today’s blog? None, except that this task requires me to travel from my building to another building located about a couple hundred yards away. Just the simple act of walking outside is enough to put one in a good mood. The weather’s a perfect 78 degrees right now with a gentle breeze, there are vibrant colored flourishing plants everywhere you look, and the sky is a brilliant blue without a single trace cloud as far as the eye can see.

Living here makes me want to be a construction worker just so I can linger outdoors as often and as long as possible. If I could get a LAN connection from outside my building, you’d probably find me camped out on a patch of lush grass in the sunshine coding away. It’s not too painful walking back into the confines of my ultraviolet illuminated, windowless office; knowing that today is Friday which means tomorrow I’ll spend a good part of the day drinking, socializing and sunning myself on the beautiful sands of Pacific Beach followed on Sunday by a nice walk with my dog down to the local Starbucks where I’ll sit outside; my top half in the shade, and bottom half in the sunshine, sip my ice-coffee, read, study, and watch the foot traffic go by.

God, I love this place.

December 12, 2007 Posted by | MISC | Leave a comment

So I’m a Yuppie? There are worse things.

YuppiesI finally tried it. I did, I really did. Yesterday I drove 6 blocks out of my way to get my morning coffee at the local one-of-a-kind, not-some-giant-chain coffee shop named Influx.
And I did it again this morning.
And tomorrow, I’m going back to my Starbucks.
You can go ahead and hate me if you want, but I love Starbucks. I love coffee. And I love that I can be in virtually any city in the world and still get exactly the coffee I’m used to prepared exactly the way I’m used to.
I’ve heard about all the evil and devious things Starbucks does to chase away helpless, tiny, little, local coffee shops just so they can rule the coffee world and make a few more bucks. But I don’t care.

The Influx Cafe is everything Starbucks haters love; it’s hip, it’s reasonably priced, it’s got eclectic, healthy food like sandwiches with beets and sprouts, and it’s chock full of all sorts of interesting people who would probably be fascinating to talk to, but I don’t care.

On a good day, I spend approximately 3.5 minutes in my local Starbucks, getting my morning coffee, and that’s how I like it. Because, true to my nature of Yuppie-dom, I must hurry off to work so I can make my millions. But what’s so wrong with that? Why should I have to apologize for appreciating efficiency and convenience? Well, I’m through apologizing, I’m through cringing in anticipation of people’s reaction when I tell them how much I love Starbucks, and I’m through strategically concealing my Starbuck’s cup as I sneak past the locally owned coffee-cart outside my office building.

Loving Starbucks doesn’t make me a money hungry, self-absorbed, victim of corporate America anymore than hating Starbucks makes those who do, tree-hugging, starving-artist, hippies.

December 12, 2007 Posted by | MISC | Leave a comment

Good ‘Ole Engineering Estimates…

Question Mark

Just how much dynamite does it take to blow up a whale? Apparently less than half a ton.


Exploding Whale – November 12, 1970, Florence, Oregon

December 12, 2007 Posted by | MISC | Leave a comment

Cooking With XSLT

cooking1.gif At the risk of sounding like the biggest geek in the world (waaaaay to late in the game to be worried about that anyway) – XSLT is starting to reveal itself as a remarkably flexible language with a high coolness factor. Short for eXtensible Stylesheet Language Transformation. XSLT is a functional language designed to transform XML into HTML, XHTML, PDF, other XML formats, or basically anything else you want to output from it. XML is basically just style-stripped text organized into a meaningful hierarchical format. If you’ve every worked with SGML, XML is basically just the well-formed version of SGML (think Twins, the movie, with Schwartzneggar and DeVito – XML is the kid every parent wishes for and SGML is its job-hopping, looser, screw-up brother).

Anyhoo, back to the coolness factor surrounding this language. I first had the pleasure of working with XSLT when a former employer dubbed me the team “Stylesheet Expert” and tasked me with converting numerous XML military technical manual documents into HTML and PDF format. I refer to it as a pleasurable experience now, but the language of XSLT is very far removed from the functionality of most other mainstream languages out there (C, C++, C#, Java, etc.) and it was a serious pain in the brain trying to understand how it does what it does. For instance, XSLT does not have true variables in the way most other languages do, rather its variables are more like constants and the language itself is purely recursive, not iterative; another far cry from most other languages I’d worked with.

In spite of our initial quarrels, eventually XSLT and I learned to get along quite well and my most recent employer stumbled onto my hidden talent and tasked me with developing stylesheets for their military technical manual XML documents. This time, though, I had some slightly more severe requirements from the client and I’ve gotten a real taste of just how powerful XSLT can really be.

The website itself was quite straight-forward; some simple Javascript for dynamic table of contents behavior, a slew of internal/external cross-document links, but otherwise quite static and mellow. There was, however, an enthusiastic request for some search box functionality. Not a big deal until I learned the clients (military peepz) were not real excited about any third party packages or extensions being included on the distribution CD and the red tape required to get approval for such an inclusion was soooooo not worth the time or effort.

After some google searching I found a couple of simple scripts that would strategically escape a search phrase typed into a text-box and then hunt through delimited strings of text within an array for a match. Would this be a truly useful methodology for a traditional website; probably not if it were a sizable site with plentiful content, but for my situation, it was absolutely perfect. I could dynamically construct, not only the Javascript itself, but the javascript array of content; dividing the text into chunks according to the pages and URLS I was creating on the fly. It worked like a charm and took me maybe a couple of hours to write code that filled a couple thousand element sized array with every bit of content of the entire website. And best of all, I would never have to worry about updating the array when changes/additions were made to the site content; just a simple command line utility to reprocess the updated XML and viola – any new content is automatically integrated into the site.

Composing a website using XSLT is alot like writing a recipe that matches all the ingredients you already happen to have lying around your kitchen, to prepare exactly the meal you’re craving. XSLT is not necessarily ideal for all situations, but if you’re responsible for maintaining/developing multiple sites with virtually identical templates, or the content of your site changes heavily and frequently, but the template in which you display it does not, ooooor you’re just a big geek like me and feel like tinkering around with some “cool” [in every un-cool sense of the word] technology – then take it for a test drive.

Some useful links:

There is no ‘I’ in style-sheet so feel free to drop me a line if you need any assistance my fellow XSLT-ers.
Good luck and happy transforming!!

December 12, 2007 Posted by | Tech | Leave a comment