<< Click to Display Table of Contents >> Navigation: ThinBASIC Modules > ADODB > ADODB Module Classes > ADODB_Connection > ADODB_Connection Methods > <ADODB_Connection>.LookUpField |
Description
Create an SQL look up statement in order to search for a specific field value
Syntax
s = <ADODB_Connection>.LookUpField (sTable, sFieldName, sWhere [, sOrderBy])
Returns
String.
Parameters
Name |
Type |
Optional |
Meaning |
sTable |
String |
No |
Name of the table in which to search |
sFieldName |
String |
No |
Name of a field to get data from |
sWhere |
String |
No |
SQL WHERE clause to apply (do not specify WHERE but only search criteria) |
sOrderBy |
String |
Yes |
SQL ORDER BY clause if necessary (do not specify ORDER BY but only fields to be ordered) |
Remarks
This function is not a standard ADODB function but a personalized thinBasic function.
It was designed because very often, when handling data from a DB, it is necessary to lookup just one value giving a SQL statement.
Instead to instantiate an ADODB_Recordset to just do one lookup, use this function.
This function will create a SQL statement assembling passed parameter in the following form:
SELECT TOP 1
sFieldName
FROM
sTable
WHERE
sWhere
ORDER BY
sOrderBy
<ADODB_Connection>.LookUpField will store previous recordset look up Table, Where and OrderBy data in order to be able to make consecutive field searches calling <ADODB_Connection>.LookUpField.Next method
Restrictions
This function will consider only the very first record (if any) from the temporary recordset that will be internally created.
See also
Examples