Xbasic
SQL::ConnectionToOpenTable Method
Syntax
Result_Flag as L = ToOpenTable(SQLStatement as C, [Arguments as SQL::Arguments,] LocalTable as P [, Append = .t. as L [, EventScript = as C [, MapByPosition = .f. as L ]]]])
Arguments
- SQLStatementCharacter
The SQL query that selects the data to retrieve.
- ArgumentsSQL::Arguments
A SQL::Arguments object. One or more arguments to be resolved when the SELECT statement is executed.
- LocalTablePointer
A pointer to an open Alpha Anywhere table.
- AppendLogical
Default = .t.
- EventScriptLogical
Default = ""
- MapByPositionLogical
Default = .f.
Returns
- Result_FlagLogical
TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).
Description
Fetch data to an open .DBF table using a SQL query.
The ToOpenTable() method fetches results from a SQL database to an existing and open .DBF table. Columns in the query must match the type of the columns in the table. The query must not have more columns than the table.
The column types returned for each column by the query must match the respective column in the local table.
Because the args argument precedes the tbl argument, this example dims and passes it.
dim conn as SQL::Connection
dim args as SQL::Arguments
dim connString as C
dim query as C
dim tbl as P
query = "select firstname, lastname from customer where lastname > 'm'"
connString = "{A5API='Access', FileName='c:\program files\a5v8\mdbfiles\alphasports.mdb'}"
if .not. conn.open(connString) then
ui_msg_box("Error", conn.CallResult.text)
end
end if
tbl = table.open("customer")
if .not. conn.ToOpenTable(query, args, tbl, .t.) then
ui_msg_box("Error", conn.CallResult.text)
end if
conn.close()See Also