>Cetin,
>
>>Why are you trying to create such a string in the first place? Is it a cursoradapter or SQLExec() string? If so you better use parametric insert. ie:
>>
>>cInsertCommand = "insert into mytable (mydtfld) values (?m.ltDatetime)"
>>m.ltDatetime = datetime()
>>SQLExec(m.lnHandle, m.cInsertCommand)
>>
>
>I am trying to create a 3-tier application where the UI tier passes an array of field/value pairs to the Data Access tier. Then in the Data Access tier I need to update database, either VFP or SQL Server. So I am experimenting with different approaches. I use SQLExec for the SQL Server, by the way, not a cursoradapter. So, for the VFP database, I was building this long string of fields and values. I am trying to make the routine somewhat generic, that's why I was building the Insert string in the Data Access tier.
>
>If you see that I am not on the right track with this approach, please let me know. Thank you.
And I missed you were saying field/value parameters. Then your routine could build it like this:
(warning off the top off my head):
set textmerge to memvar m.lcInsert noshow
set textmerge on
\\insert into <<tcTableName>> (
for ix=1 to alen(taFVPair,1)
\\ <<iif(m.ix>1,',','')>><<taFVPair[m.ix,1]>>
endfor
\\) values (
for ix=1 to alen(taFVPair,1)
\\ <<iif(m.ix>1,',','')>>?taFVPair[<<m.ix>>,2]
endfor
\\)
set textmerge to
set textmerge off
SQLExec(m.tnHandle,m.lcInsert)
PS:This is if passed pairs as an array. Similar routine could be done using amembers() if you instead passed oRecord where Columns are properties (ie: what a scatter name creates).
Cetin