Wednesday, February 27, 2008

SQLStatement lesson

I've been working a lot with the new built-in database that comes bundled with AIR and I ran into something that gave me a bit of trouble.
It was retrieving some info from the database and reading the SQLResult using the getResult() in my retrieving method from my SQLStatement. Like usual, I was trying to read if the method was called using a trace statement and also tracing out the result using getResult(). With the trace statement, I was reading everything fine, but when I went to evaluate the SQLStatement again using getResult(), I always got NULL. How can this be? I traced out a result!? Well it turns out (if you read the help files carefully) that "When there are no more SQLResult objects left in the queue, getResult() returns null." So even tracing out getResult() removes it from the SQLStatement queue! So be warned, pass it to a variable BEFORE reading it and you'll save a lot of time troubleshooting!

Another lesson learned, but it wouldn't fun if it wasn't ;)

0 comments: