Depending on the data type used, many databases (for example, Microsoft SQL Server) pad returned data with spaces up to the length of the field. This is not a problem when fields are displayed (even if there is extra white space HTML will ignore it), but this can be quite annoying if the field is used to populate a FORM field (using the tags VALUE attribute). The solution? Any time you use a database field to populate a form field make sure to use the Trim() function (or the RTrim() function) to strip any trailing white space, so instead of VALUE=”#name#” use VALUE=”#Trim(name)#”. (Applies to: ColdFusion All)

Leave a Reply