Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unicode, SQL Server & VFP
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00868251
Message ID:
00909471
Views:
8
Terry,

>CAST() in TSQL?

If you can get something to work I'd be interested in seeing it. I got unicode data down from the server as long as it came in as a VFP memo field. The problem was getting a unicode string back up to the server. The problem was that VFP was adding chr(0) between every byte of unicode string which is quite incorrect so a N'Test' string comes down correctly as T0e0s0t0 but was going back up as T000e000s000t000.

The only mechanism I found to get a unicode string back to SQL via SPT was to use this function on them:
function StrToNchar( lcStr )

local lcRetVal, i, lnLen

lcRetVal = ""
lnLen = len( lcStr )

if ( lnLen % 2 = 1 )
   * unicode strings must have lengths that are divisible by 2
   * pad this out with a null character
   lcStr = lcStr + chr( 0 )
endif

for i = 1 to lnLen step 2
   lcRetVal = lcRetVal + "+nchar(" + transform( asc( substr( lcStr, i+1, 1 ) ) * 256 + asc( substr( lcStr, i, 1 ) ) ) + ")"
endfor

if ( lnLen > 0 )
   lcRetval = substr( lcRetVal, 2 )
endif

return lcRetVal
ala:
select testthis
scan for "descript" $ lower( name )
   SQLExec( gnSQLConnection, "insert into testunicode ( descript ) values (" + ;
      StrToNchar( strconv( testthis.value, 12 ) ) + ")" )
endscan
In the above code testthis.descript was UTF8 data coming from an ADO recordset off an ASP page.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform