Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Read unicode-data from MDB-files

Status
Not open for further replies.

thuvan1957

Programmer
Oct 29, 2003
29
0
0
VN
I have table customer in access file MyDATA.MDB , that have column C_Name in unicode form (2byte-font). I need read original data from this column. Any one have me?
Thanks
PS: The folow-code dosn't help:

strConn = "DRIVER=Microsoft Access Driver (*.mdb);" ;
+"ADOCodePage=65001;" ;
+"UserCommitSync=Yes;" ;
+"PWD=123456;" ;
+"Threads=3;" ;
+"SafeTransactions=0;" ;
+"PageTimeout=5;" ;
+"MaxScanRows=8;" ;
+"MaxBufferSize=2048;" ;
+"FIL=MS Access;" ;
+"DriverId=25;" ;
+"DefaultDir=;";
+"DBQ=MyDATA.MDB"
MyConn= CREATEOBJECT("ADODB.Connection")
MyConn.CONNECTIONSTRING= strConn
MyConn.Open()
Customer= CREATEOBJECT("ADODB.Recordset")
Customer.Open("Customer", MyConn, 2, 2, 2)
Store Customer.Fields("C_Name").Value to O_Value
?O_Value
....
But I get UDF8-string
thanks
thuvan
 
Perhaps the following VFP function would help you in your endeavour?

STRCONV(cExpression, nConversionSetting [, nRegionalIdentifier [, nRegionalIDType]])


boyd.gif

 
Thuvan,

If you are sure that the text is in a Western European or other 8-bit character set, you only need to strip out the binary zeroes, which will occur in every second character.

This should do it:

? strtran(o_value, chr(0), "")

If the text is in a 16-bit format, such as Arabic or Simplified Chineses, it will be much more difficult.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
? strtran(o_value, chr(0), "")
dosn't help, because o_value - 8-bit format,
C_name - 16 bit-format. I need read 16-bit format from C_name (text is in a 16-bit format vietnamese language)
Can you help me, Mike ? That realy very difficult!!!
Thanks
Thu Van
 
Check out an article by Rick Strahl in the March FoxPro Advisor. He covers dealing with Unicode in a lot of detail.

Tamar
 
Tamar !
I am read this article, but this code do not work on VFP-7.0 and ADO, this code for VFP 9.0 and SQL-Serve:

LOCAL oCA as CursorAdapter
oCA = CREATEOBJECT("CursorAdapter")
oCA.ADOCodePage = 65000
oCA.Alias = "TSqlQUery"
oCA.DataSourceType = "ADO"
oCA.DataSource = oRS
...
TEXT TO lcSQL NOSHOW
select ID,
CAST( CAST( Descript as nVarChar(4000) ) as VarBinary(8000) ) as Note,
CAST( CAST( lDescript as nVarChar(4000) ) as VarBinary(8000) ) as Description
from ForeignData
ENDTEXT

lnResult = SQLEXEC(lnHandle,lcSQL,"TFData")

= error =

Thank
Thu Van
 
I'm confused... STRCONV() appears to have the ability to handle this for you (double-byte, single-byte, unicode, and UTF-8 are all within its ability to handle). I just checked and it was part of the language base in VFP 7. This question is to anyone... Why is STRCONV() not a viable option?

boyd.gif

 
My problem consist in that: I cann't read 16-bit data text from access table (in MDB file). This text automatical converted to UTF8 (when I do command: select * from Mytable or Open-recordset ) and I cann't modify text in unicode format (16bit), after that update new-value revert to table! Can you help me - craigsboyd?
Thanks
Thu Van
 
Craig,

Why is STRCONV() not a viable option?

Basically, it's because VFP can only support one code page at a time. If your PC has an Western European version of Windows, and is configured for the corresponding code page (such as 1252), VFP isn't going to be able make sense of 16-bit character sets like Arabic or Chinese. You can use STRCONV() to make the conversion for a different code page, but there would be no way of displaying it using native VFP controls.

The only really satisfactory way to solve the problem is to use a third-party ActiveX control that supports Unicode natively.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top