DbSelect
ODBC function.
The DbSelect function creates the dataset by selecting the desired records in the ODBC database. Not available in WinTask Lite.
Syntax
DbSelect(<SQL_selection>[,DYNASET|SNAPSHOT])
or
Ret=DbSelect(<SQL_selection>[,DYNASET|SNAPSHOT])Parameters
<SQL_selection>, string, SQL request which specifies the records to select in the ODBC database previously connected using the DbConnect function. In case <SQL_selection> is a complex one, it is recommended to create it as a string, to display it for checking using msgbox statement, and then to use it in DbSelect statement - see the example below.
DYNASET or SNAPSHOT, optional keywords. It specifies how the database must be read, SNAPSHOT (default value) for ODBC static mode, DYNASET for ODBC dynamic mode.
If your ODBC driver displays error messages, try to add the DYNASET keyword.
Return value
Ret, numeric return code. If the selection has been performed successfully, the function returns 0, otherwise use this return code for error management.
Examples
DbConnect("DSN=gpao;PWD=SILOG") ' connection to ODBC database called gpao
DbSelect("SELECT * FROM Business",DYNASET) ' select all records in table Business.
With a complex SQL syntax :
DbConnect("DSN=gpao;USER=SILOG")
my_request$="SELECT CodeArticle.ARTICLE,Designation1.ARTICLE FROM LCTC,ARTICLE WHERE CodeRubrique.LCTC=CodeArticle.ARTICLE AND CodeLancement.LCTC='10000' AND TypeRubrique.LCTC='A'"
msgbox(my_request$)
lct$="10000"
my_request1$="SELECT CodeArticle.ARTICLE,Designation1.ARTICLE FROM LCTC,ARTICLE WHERE CodeRubrique.LCTC=CodeArticle.ARTICLE AND CodeLancement.LCTC= '"+lct$+"' AND TypeRubrique.LCTC='A'"
msgbox(my_request1$)
DbSelect("SELECT CodeArticle.ARTICLE,Designation1.ARTICLE FROM LCTC,ARTICLE WHERE CodeRubrique.LCTC=CodeArticle.ARTICLE AND CodeLancement.LCTC='10000' AND TypeRubrique.LCTC='A'",DYNASET)