frankthefixer
Posts: 52
|
| Posted: 06/25/2010, 2:38 PM |
|
Hello. I'm using a DLookUp to populate the value of one field based on another. The code works fine if the returned value in the 'Where' clause is a number, but not when it's text. The field is a serial number field which is a text field because they often contain alphanumerics.
I had:
$ccs_result = CCDLookUp("RecID", "RcvSerial", "Serial=".$Container->Serial->GetValue(),
i noticed after a while it only returned RecId's for serials that happend to be numerical, when a serial came over that had text it failed. I clumsily tried this:
$ccs_result = CCDLookUp("RecID", "RcvSerial", "Serial=".$Container->Serial->GetText(),
and single quoting it lke this:
$ccs_result = CCDLookUp("RecID", "RcvSerial", "Serial="'.$Container->Serial->GetValue()',
but to no avail- i'm no expert in php and did many searches for dlookup where clause and codecharge dlookup where but am stuck. i appreciate any help-
Thanks
|
 |
 |
frankthefixer
Posts: 52
|
| Posted: 06/25/2010, 7:30 PM |
|
did it like this:
$ccs_result = CCDLookUp("RecID", "RcvSerial", "Serial=" .$db->ToSql($Container->Serial->GetValue(),ccsText)
|
 |
 |
datadoit
|
| Posted: 06/26/2010, 6:48 AM |
|
That's the correct way to use DLookUp, via CCToSQL(), or just ToSQL().
Those functions basically determine whether single quotes are needed
around the condition.
Going forward, you should make a common practice of always using ToSQL()
in all of your custom coded conditions, as it also protects your
application from SQL injection attacks.
|
|
|
 |
frankthefixer
Posts: 52
|
| Posted: 06/26/2010, 9:38 AM |
|
thanks for the tip datadoit
|
 |
 |
|