>Hi
>
>I'm using Cursoradapter with SQL Server
>
>I Used ConversionFunc prporty in the design mode to TRIM the Fields but the ConversionFunction preporty is not working. need help
>
>Regards
>Anwar
Hi Anwar,
The following code demonstrates how to use ConversionFunc property. The BeforeUpdate event handler prints UPDATE command being executed, the command has parameter ?RTRIM(myca1.f2) and the EXP field in the last output doesn't have spaces between bbbb and X. But, if you comment the line oCA.ConversionFunc="f2 RTRIM", UPDATE command will not contain RTRIM function and EXP field will have spaces between bbbb and X.
CLOSE DATABASES all
clear
con=SQLCONNECT("LocalServer")
IF con<0
? "Failed to connect!!!!"
ENDIF
SQLEXEC(con,"SET ANSI_PADDING ON")
SQLEXEC(con,"create table #test (f1 int, f2 varchar(10))")
SQLEXEC(con,"insert into #test values(1,'aaaa')")
LOCAL oCA as CursorAdapter
oCA=CREATEOBJECT("MyCa")
oCA.DataSourceType="ODBC"
oCA.DataSource=con
oCA.SelectCmd="SELECT * from #test"
oCA.Tables="#test"
oCA.KeyFieldList="f1"
oCA.UpdatableFieldList="f2"
oCA.UpdateNameList="f1 #test.f1, f2 #test.f2"
oCA.ConversionFunc="f2 RTRIM"
oCA.CursorFill()
SELECT (oCA.Alias)
GO top
replace f2 WITH 'bbbb '
SKIP
USE
SQLEXEC(con,"select f2, f2+'X' from #test","res")
SELECT res
list
DEFINE CLASS MyCA AS CursorAdapter
FUNCTION BeforeUpdate(cFldState, lForce, nUpdateType, cUpdateInsertCmd, cDeleteCmd)
? cUpdateInsertCmd
ENDFUNC
ENDDEFINE
Be aware that SQL Server may pad character fields with spaces, for more information read help topic about SET ANSI_PADDING ON.
Thanks,
Aleksey.