ConnectionNum is int SourceName is string // Connection to a specific data source via ODBC MS ACCESS SourceName = "MS Access 97 Database" ConnectionNum = SQLConnect(SourceName, "", "", "", "ODBC") // <-------- IF ConnectionNum <> 0 THEN // The connection was successful
// Run the query and retrieve the result line by line i is int = 0 SQLExec("SELECT LASTNAME, FIRSTNAME, EXTENSION, PHOTO FROM CUSTOMER", "QRY1") // <-------- WHILE SQLFetch("QRY1") = 0 // There is still another line to read i++ // Retrieve the data LASTNAME[i] = SQLGetCol("QRY1", 1) FIRSTNAME[i] = SQLGetCol("QRY1", 2) EXTENSION[i] = SQLGetCol("QRY1", 3) {"IMAGE"+i} = SQLGetMemo("QRY1", 4) END SQLClose("QRY1")
ELSE // The connection failed: display an error message SQLInfo() Error("The connection to the data source " + SourceName + " failed." + CR + ... "Error code: " + SQL.Error + CR + SQL.MesError)
END // In any case (connection OK or not) SQLDisconnect() // <-------- |