set @my_balance = select sum(savings_balance) from client_accounts where savings_balance > 0.00

July 25, 2007 under ASP.NET, C++, IIS

Today’s Daily WTF post was one of their funny screenshot articles and one of them struck me as being quite familiar:

IIS Error Message on a Diebold ATM

Die-hard readers of my blog may be thinking that based on the Diebold logo in the picture, that I’m reminded of one of my rants against slow Diebold ABMs. It’s not. That “Object reference not set to an instance of an object” ASP.NET error is the one that makes me shudder – more so, since this is a banking application.

Sometimes this is caused by trying to access variables and object beyond the current scope, but Visual Studio can notice these more often than not during a build. Where I really get nabbed is when trying to access a null object. Sure, sometimes it’s just a slight oversight on my part and I try to access an objects methods and properties without actually instantiating it first. Hey, it happens. Yet, often I find that an object doesn’t instantiate and I don’t find until much later….like runtime later. So I’m now conditioned to try to catch everything:

   MyCoolClass myobject = null;

   try
   {
      myobject = new MyCoolClass();
      myobject.someVoidMethod(SOME_CONSTANT);
   }
   catch (Exception ex)
   {
      Response.Write(ex.Message.ToString());
   }
   finally
   {
      myobject = null;
   }

That’s my two cents, anyway 😉

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
comments: 0 »

server.transfer() saved my asp

September 25, 2006 under ASP, IIS, Programming

At work, I’m near completion of an ASP ecommerce project. Up to this point in my life, I had never coded with anything other than Perl or PHP running on Apache when working on web-based projects that required dynamically generated content. So this project stole my ASP-on-IIS virginity; this is a good thing.

Server.Transfer() is a useful method that I stumbled upon by accident. I had an ASP script that was called from a POSTed web form. Said script took the form data, did some stuff, and needed to post one of two possible forms, depending on the data. I knew that out-of-the-box, PHP has no way to accomplish this. I became nauseated, believing that I’d have to generate a new form on the fly, complete with some JavaScript to be called in the BODYs onLoad event so as to post the form automatically. Ugh. Then, a gift from the heavens, “heavens” being a Google query, bestowed Server.Transfer() upon me. I found Response.Redirect() as well, but that totally smacked of PHPs header() function, which won’t submit form variables via a POST request, and would not be of any help.

If we’re on a.asp, which contains a bunch of form elements, and we want to go to b.asp, we can do the following:

< %
   ' Go to b.asp and preserve all of the form elements from a.asp.
   Server.Transfer("b.asp")
%>

Now from b.asp, we can retrieve the form elements that were on a.asp via the Reponse.Form() method. You just have to be careful as to what is already written to the browser prior to calling Server.Transfer() as it won’t be requesting a brand new page like Response.Redirect() would. Server.Transfer() is, thankfully, also available to ASP.NET.

This is probably old hat to all of the ASP veterans out there in Internet land, but it’s new to me and I’m glad that it exists 🙂

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
comments: 0 »