|
This question
can be used to evaluate the skills of a junior level ASP web
developer. A candidate with 1-2 years experience should be
able to answer the following question correctly. This is a
common task when developing Visual Basic applications.
The
following code fragment is from an ASP page being hosted on
a Windows 2000 Server using IIS 5.0. What is the best way
in ASP VBScript to determine if the recordset shown below
has no records? Line numbers are shown for referential
purposes and are not part of the code.
1
Dim rs
.
. (more code is here)
.
9
10 SET rs = LoadRecordSetWithData (SomeInputParameter)
11
.
. (more code is here)
.
a. Insert the following code at line 11
IF ISEMPTY(RS) then ...
b.
Insert the following code at line 11
IF RS = "" then...
c.
Insert the following code at line 11
IF (RS.Eof) AND (RS.BOF)
THEN ...
d.
Insert the following code at line 11
IF ISNOTHING(RS) then
...
e.
Insert the following code at line 9
On error goto Error_check
And
insert the following code at line 11-12
Error_check:
IF (RS.Eof) AND (RS.BOF)
THEN ...
The correct answer
is c. The .EOF and .BOF properties of the recordset will both
be true if there are no records in the recordset.
a.
Incorrect.
ISEMPTY is used for numeric or string variables not recordsets.
Candidates that select this answer don't understand recordsets,
but may have a basic knowledge of ASP code.
b.
Incorrect.
You cannot test a recordset by using the empty set. Candidates
that select this answer don't understand recordsets, but may
have a basic knowledge of ASP code.
d.
Incorrect.
Isnothing is not a function in VBSCRIPT, however objects can
be tested using the following syntax
if varX is
nothing then...
However this method
cannot be used to test if there are no records in a recordset.
e.
Incorrect. You
cannot use On error goto line_label in VBSCRIPT although it
is valid in visual basic.
About
the author
Mark Horninger, A+, MCSE+I, MCSE, MCSD, MCDBA, is President
and founder of Haverford Consultants Inc. (http://www.haverford-consultants.com),
located in the suburbs of Philadelphia, PA. He develops custom
applications and system engineering solutions, specializing
primarily in Microsoft operating systems and Microsoft BackOffice
products. He has over 12 years of computer consulting experience
and has passed 31 Microsoft Certification Exams. During his
career, Mark has worked on many extensive and diverse projects
including database development, client server and web-based
application development, training, embedded systems development
and Windows NT and 2000 project rollout planning and implementations.
Mark is a contributing author to the following books: MCSE
Windows 2000 Professional Study Guide, Designing SQL Server
2000 Databases for .NET Enterprise Servers, VB .NET Developers
Guide and Configuring and Troubleshooting Windows XP Professional.
Mark lives with
his wife Debbie and three children in Havertown, Pa. and can
be reached at mark@haverford-consultants.com
or markh@op.net.
|