Xbasic

SQL::ResultSet::ToGridComponentDataObject Method

Syntax

Result_Flag as L = ToGridComponentDataObject(DataArray as p[], FieldArray as p[], [, RowsToCopy = -1 as N [, StartRow = -1 as N ]])

Arguments

Result_Flag

TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).

SQL::ResultSe

A SQL::ResultSet object created with a DIM statement.

DataArray

Pointer array.

FieldArray

Pointer array.

RowsToCopy

Optional. Default = -1 (all rows).

StartRow

Optional. Default = 1 (first row).

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
dim rs as SQL::ResultSet
dim connString as C
dim select_exp as C
dim data_array0 as P
dim field_array0 as P
dim DataValues as C
dim Size as N
dim i as N
dim j as N
connString = "{A5API='Access', FileName='c:\dev\a5v8\bin\dbg\mdbfiles\alphasports.mdb'}"
select_exp = "select * from customer"
if .not. conn.open(connString)
    ui_msg_box("Error", conn.CallResult.text)
    end
end if
if .not. conn.execute(select_exp)
    ui_msg_box("Error", conn.CallResult.text)
    conn.close()
    end
end if
   
rs = conn.ResultSet
if .not. rs.ToGridComponentDataObject(data_array, field_array) then
    ui_msg_box("Error", rs.CallResult.text)
end if
conn.close()
Size = data_array.size()
for i = 1 to Size
    DataValues = DataValues + "Row " + i + "" + crlf()
        for j = 1 to data_arrayi.data.size()
            DataValues = DataValues + "Column [" + j + " - " + Field_arrayj.name + "(" + Field_arrayj.type + ")] Initial/Current: "
            DataValues = DataValues + "" + iif(data_arrayi.dataj.IsNull, "NULL", "" + data_arrayi.dataj.initial)
            DataValues = DataValues + "/" + iif(data_arrayi.dataj.IsNull, "NULL", "" + data_arrayi.dataj.current)
            DataValues = DataValues + crlf()
        next
    DataValues = DataValues + crlf()
next
showvar(datavalues)

See Also