SQL::ConnectionToDBF Method
Syntax
Arguments
- Result_Flag
TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).
- SQL::Connection
A SQL::Connection object.
- SQLStatementCharacter
A SQL SELECT statement.
- ArgumentsSQL::Arguments
A SQL::Arguments object. One or more arguments to be resolved when the SELECT statement is executed.
- FileNameCharacter
The path and name of the Alpha Anywhere .DBF table to be created.
- AppendLogical
Default = .t.
- .T. = If the file exists, AlphaDAO will add or replace records.
- .F. = AlphaDAO will overwrite an existing file.
- EventScriptLogical
Default = "". EventScript is an Xbasic Script implementing any of the following functions. In each case, the Context argument is the connection itself.
- UpdateBegin()
- UpdateProgress()
- UpdateEnd()
- MapByPositionLogical
Default = .F. If the query has named columns differently than in an existing table, you will want to map by position.
- .T. = Columns will be mapped by position.
- .F. = Columns will be mapped by name.
- LocalTableDefinitionSQL::TableInfo
A SQL::TableInfo object. The definition for the new table will be taken from the result set unless an (optional) SQL::TableInfo object is passed in. In this case, overrides will be honored. The columns in TableInfo must match the columns in the result set by type, but need not match by length, precision, or name (if MapByPosition is true).
Returns
- Result_FlagLogical
TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).
Description
Fetch data to a local .DBF table using a SQL query
Discussion
The ToDBF() method fetches rows to a new or existing .DBF table using a SQL query. The function supports options for specifying a unique key to update local table against. If ReturnRow is passed, the rows are returned into this variable.
Example
dim conn as SQL::Connection dim sql as C dim vCity as C dim args as SQL::Arguments dim cs as C dim rs as SQL::ResultSet cs = "{A5API=Access,FileName='C:\Program Files\a5v8\MDBFiles\Alphasports.mdb', UserName='Admin'}" vCity = ui_get_text("City", "Show Companies in what city?") sql = "select lastname, firstname from customer where bill_city = :city Order By Company" if .not. conn.open(cs) ui_msg_box("Error", conn.CallResult.text) end end if if .not. args.Set("city", vCity) conn.close() end end if if .not. conn.execute(sql, args) ui_msg_box("Error", conn.CallResult.text) conn.close() end end if rs = conn.ResultSet if .not. rs.ToDBF("c:\program files\a5v8\samples\alphasports\newtable2.dbf", "", 3, 1 ) ui_msg_box("Error", conn.CallResult.text) end if conn.close()
See Also