I try to create a function that read MySQL record based on a criteria and return a particular field value,
but can not find a way to pass a $sField parameter:
On the line 10, the correct command is something like:
But since this is a function, I need to bypass "fieldname" to whatever the value is the $sField parameter when this function get called
Try many variation including
But then $try will contain string ".Fields ("fieldname").value" instead of execute that command and store the value.
but can not find a way to pass a $sField parameter:
Func ReadDatabaseMySQL($sSearchField, $sSearchKey, $sTable, $sField, $sUserName, $sPassword, $sDatabase, $sServerName) Local $SQLCode, $TableContents = "" Local $searchresult = "" local $try $SQLInstance = _MySQLConnect($sUserName,$sPassword,$sDatabase,$sServerName) $SQLCode = "SELECT * FROM " & $sTable & " Where " & $sSearchField & "='" & $sSearchKey & "'" $TableContents = _Query ($SQLInstance, $SQLCode) With $TableContents While NOT .EOF $try = ".Fields "& '("' & $sField & '").value' $searchresult = $try .MoveNext WEnd EndWith _MySQLEnd($SQLInstance) Return $searchresult EndFunc
On the line 10, the correct command is something like:
$try = .Fields ("fieldname").value
But since this is a function, I need to bypass "fieldname" to whatever the value is the $sField parameter when this function get called
Try many variation including
$try = ".Fields " & '("' & $sField & '").value'
But then $try will contain string ".Fields ("fieldname").value" instead of execute that command and store the value.