Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

[ASK] MySQL and String problem

$
0
0
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:

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.

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>