Xbasic
SQL::ResultSetToGridComponentDataObject Method
Syntax
Result_Flag as L = toGridComponentDataObject(DataArray as p[], FieldArray as p[], [, RowsToCopy = -1 as N [, StartRow = -1 as N ]])
Arguments
- DataArrayPointer Array
A pointer array to be populated with the data in the result set.
- FieldArrayPointer Array
A pointer array to be populated with the fields in the result set.
- RowsToCopyNumeric
Default = -1. The number of rows to copy from the result set. -1 will copy all rows.
- StartRowNumeric
Default = 1. The starting row. 1 will start at the first row of data.
Returns
- Result_FlagLogical
TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).
Description
Convert the ResultSet to a Grid Component DataObject data and field arrays.
Discussion
The ToGridComponentDataObject() method converts the SQL::ResultSet to a Grid Component DataObject data and field arrays. This function is intended to be used with the Alpha Anywhere Grid Component and may create different formats in the future.
Example
dim conn as SQL::Connection
if .not. conn.open("::Name::AADemo-Northwind")
ui_msg_box("Error", conn.CallResult.text)
end
end if
dim select_exp as C = "select * from customers"
if .not. conn.execute(select_exp)
ui_msg_box("Error", conn.CallResult.text)
conn.close()
end
end if
dim data_array[0] as P
dim field_array[0] as P
if .not. conn.ResultSet.ToGridComponentDataObject(data_array, field_array) then
ui_msg_box("Error", conn.ResultSet.CallResult.text)
conn.close()
end
end if
conn.close()
dim DataValues as C = ""
dim i as N = 1
dim j as N = 1
for i = 1 to data_array.size()
*concat(DataValues,"Row " + i + crlf())
for j = 1 to data_array[i].data.size()
*concat(DataValues,"Column [" + j + " - " + Field_array[j].name + "(" + Field_array[j].type + ")] Initial/Current: ")
*concat(DataValues,"" + iif(data_array[i].data[j].IsNull, "NULL", convert_type(data_array[i].data[j].initial,"C")))
*concat(DataValues,"/" + iif(data_array[i].data[j].IsNull, "NULL", convert_type(data_array[i].data[j].current,"C"))+crlf())
next
*concat(DataValues,crlf())
next
showvar(DataValues)