Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RecordSet("ColumnName") is an int? 3

Status
Not open for further replies.

coospaa

Programmer
May 1, 2003
33
SG
Hi, I was reading some VB code in a .asp file.
Here's the code"
Code:
SQL = "SELECT somedata as somedata FROM XTab ORDER BY somedata ASC"
set rs = OBJdbConnection.execute(SQL)
if rs.eof then
  ' do something
else
  [COLOR=red]xxx = rs("somedata")[/color]

Can anybody tell me what is the xxx value? Is it a int representing the smallest somedata value, or is it a array?

Thanks in advance!!
 
It is the first record in the recordset, so rs("somedata") is the first value in the somedata column. If it is an integer it is the smallest one.
 
What you are seeing is the ability of COM objects to specify one of their public properties as the "default" property.

So this:
[tt]xxx = rs("somedata")[/tt]

Is shorthand for this:
[tt]xxx = rs.Fields.Item("somedata").Value[/tt]



Fields is the default property of an ADO recordset object.
Item is the Default property of an ADO Fields object.
"somedata" is an index parameter passed to Item.
Item returns an ADO Field object.
Value is the default property of an ADO Field Object.
 
And being a default property should be avoided as if that changes then your programs are dead in the water.

As a matter of good practice (CYA) always reference the field/property you need completely.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top