Truths of the universe..

..it’s easy when you know how :)

Just spent the best part of an hour discovering that in ASP JScript you have to do query(“field”).Value to get the value of the field as a “real” jscript object that you can compare to null.

I love ASP!

Posted on 14 Sep 04 by Helen Emerson (last updated on 14 Sep 04).
Filed under Web development

Comments

Ken from Evolt 13 May 2005

Nice to see someone else from the Evolt list in Australia – so I checked out your techblog. WRT to these issues, it’s always helpful to have a good understanding of the underlying technology before you get upset at it!

VBScript (and) VB let you do

objRS(“field”)

because VB supports something called “default” properties. The “fields” collection is the default property of the recordset object, and value is the default property of an ADO Field object. So

objRS.Fields(“field”).Value gives you the same as objRS(“field”)

But if you use the latter syntax (relying on default properties), then you should realise what you are doing, so that you don’t have problems when trying to do the same thing using a different language. ADO reference documentation:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmscadoobjmod.asp?frame=true

Cheers
Ken

Helen 13 May 2005

Thanks Ken :) That bit of documentation looks like it’ll be really helpful.

Yes the fact most of the asp examples on the internet are in VBScript is a real disadvantage of doing development work in JScript because of these subtle differences. I guess the more I do this stuff, the more of these little tricks I’ll pick up.

I must admit I actually felt kind of silly because I found the answer before I actually had the problem when I was researching another problem, but I didn’t make the connection until I had spent half an hour banging my head against the desk. :)

Ken from Evolt 13 May 2005

I just reread my original comment, and realised it was a little harsher than I intended – hope it didn’t go down the wrong way. In any case, ADO is kinda deprecated these days – should be using ADO.NET instead :-)

Helen 13 May 2005

Don’t worry, I’m secure enough in my l33t web skillz to not take offense when someone suggests I don’t know everything. ;)

It was actually a bit of maintenance for one of our older ASP applications. Is it actually possible to use the new ADO.NET components with old style ASP applications? Would there be any real benefit in doing so?

I actually got my current job to work on our company’s first ASP.NET project (which I’m just putting the finishing touches on now) but unfortunately I think we’ll be doing maintenance on our old ASP sites for quite a few years yet. :)

Helen 13 May 2005

Unfortunately because I think old style ASP is just uuuuugly :)

Ken from evolt 13 May 2005

Natively from ASP? not possible. From a COM object that you instantiate in an ASP page – possible, but probably not worth it, as you point out.