Xbasic

More about the SQL::ResultSet Object

Description

While working in the Interactive window, after creating the rs SQL::ResultSet object, you could type.

? rs

The result would be a long list of methods and properties available to SQL::ResultSet objects. Here are a few methods and properties that might be of immediate value. For a full description, see SQL::ResultSet Object.

To get a count of the customer table fields, you would read the .ColumnCount property.

? rs.ColumnCount
= 20

To get a list of the customer table fields, sizes, and types, you would use the .DBFRowSyntax property.

? rs.DBFRowSyntax 
= CUSTOMER_ID,N,10,0
FIRSTNAME,C,20,0
LASTNAME,C,20,0
COMPANY,C,32,0
PHONE,C,20,0
FAX,C,20,0
BILL_ADDRESS1,C,40,0
BILL_ADDRESS2,C,40,0
BILL_CITY,C,20,0
BILL_STATE_REGION,C,20,0
BILL_POSTAL_CODE,C,10,0
BILL_COUNTRY,C,20,0
SHIP_ADDRESS1,C,40,0
SHIP_ADDRESS2,C,40,0
SHIP_CITY,C,20,0
SHIP_STATE_REGION,C,20,0
SHIP_POSTAL_CODE,C,10,0
SHIP_COUNTRY,C,20,0
SHIP_SAME,L,1,0
EMAIL,C,60,0

To get the column number of the lastname field, you would use the .ColumnNumber() method.

? rs.ColumnNumber("lastname")
= 3

To check whether current record's lastname field was NULL, you would use the .DataIsNull() method.

? rs.DataIsNull("lastname")
= .F.

To read the current record into a character variable, you would use the .ToString() method. The following command reads one record (the first parameter), starting at record six (the second parameter).

? rs.tostring(1,6) 
= 6 Jason Rigan South Bend Auto (202) 555-8100 21 Porter St. Washington DC 20000 T jason at rigan.com

The fields are separated by tab characters, so that you can extract them with the WORD() function.

? word(data, 2, chr(9)) 
= "Jason"
? word(data, 3, chr(9)) 
= "Rigan"

Close the connection when you are finished.

conn.close()

Limitations

Desktop applications only.

See Also