Foxpro & Unicode

  • Thread starter Thread starter Sascha Schmidt
  • Start date Start date
S

Sascha Schmidt

Hello !

I have a little problem accessing a Visual Foxpro-database using ODBC (Driver 6.00.8167)
(using System.Data.Odbc). Reading a column, defined in the Foxpro table definition as a kind
of binary char (i'm no foxpro-expert and the database is predetermined) and containing
Unicode-String, delivers a byte[] structure in the resulting DataSet. Showing
this column in a Datagrid only results in displaying "byte[]" instead of a value.

Now my questions:
1) Is this only a driver problem? Do i have to use another driver? OleDB?
2) In other cases: Is it possible to convert it automatically? Or do i have to
read every row, check for affected columns, convert them manually into
strings (using the Encoding-Class) and write it back to another datastructure?
(that would surely slow down performance *sigh*)
3) any other advices/hints ?

Maybe someone has faced this problem before?

Thanks in advance and greets !
Sascha
 
Sascha,

I would try the oledb provider for FoxPro, as I believe it is geared for
later versions, which have better support for unicode strings/characters.

Can you attach the DBF or DBC file so that we could try it?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hello !

I have a little problem accessing a Visual Foxpro-database using ODBC
(Driver 6.00.8167)
(using System.Data.Odbc). Reading a column, defined in the Foxpro table
definition as a kind
of binary char (i'm no foxpro-expert and the database is predetermined) and
containing
Unicode-String, delivers a byte[] structure in the resulting DataSet.
Showing
this column in a Datagrid only results in displaying "byte[]" instead of a
value.

Now my questions:
1) Is this only a driver problem? Do i have to use another driver? OleDB?
2) In other cases: Is it possible to convert it automatically? Or do i have
to
read every row, check for affected columns, convert them manually into
strings (using the Encoding-Class) and write it back to another
datastructure?
(that would surely slow down performance *sigh*)
3) any other advices/hints ?

Maybe someone has faced this problem before?

Thanks in advance and greets !
Sascha
 
Hello again!

Using the suggested OleDb-Drivers (Microsoft OLE DB Provider for Visual
FoxPro 9.0)
and OleDb (using System.Data.OleDb) did not solve the problem, the DataGrid
still
displays "Byte[] Array" and cannot be edited)
I used this connectionstring:
"Provider=VFPOLEDB.1;Data Source=C:\MyDB\bgdb.DBC;Password=;Collating
Sequence=MACHINE"
Can you attach the DBF or DBC file so that we could try it?
Sure, but i think it's not possible to add it to my newsgroupposting.
Maybe i can send it to an email address? (The zip-file's size is about 109
kB,
quite small).

Greets
Sascha
 
Hi Sascha,

You can send it (code sample, and all relevant data) to me and I'll play
with it.
 
Hi Sascha,

Sorry I took so long to look at what you sent me offline.

The affected fields in your table are Visual FoxPro data type "Character
(Binary)" with field widths varying from 64 to 144. Character (Binary) field
types were in use in VFP6; the ODBC driver does not support data features
added after VFP6. Of course the OLE DB data provider is preferred. The field
names are McName, LotName, SpiMerge, Remarks, LabelName, Twist, PoyID, and
PoyDoff. Here's what the VFP9 Help says about Character (Binary) field
types:
Visual FoxPro Field Types
Character (Binary): Any Character data that you do not want translated
across code pages. For example, user passwords stored in a table and used in
different countries or regions.
<<

Here's something I found in a Google search:Matt Campbell Apr 12 1999, 12:00 am:
"Fellow developers,
I recently posted a question asking if anyone knew how to convert "Character
(binary)" type data selected back from a VFP database into something
readable by VB. After I tried a lot of things ....Msoft Support came up with
an answer. You have to add two single quote chars and a "+" before the name
of the field holding the "Character (binary)" type data in the SQL query, as
in:

' These are 2 single quotes---V
rs.Open "Select usr_lanid, ''+usr_password as usr_password FROM users",
cnMain, adOpenStatic, adLockReadOnly

where the field usr_password is of the "Character (binary)" data type. The
data returned as usr_password will be readable by VB string-reading
functions.

Why this would work, I don't know. I will take an educated guess that by
adding ''+ to the field, you are signaling the OLE DB driver that the field
is of "Character (binary)" type and to cast is at a string.
<<

It's getting late here, so I haven't actually tried this yet.
 
Hi Cindy,
using this workaround changes the situation a little bit, the first letter
of the string is
displayed.

I decided to use a kind of "brute-force-implementation", building a new
DataTable, set
the column data type from byte[] to string, afterwards copying every row,
converting
(--> Encode) relevant cells.

Another solution might be to use DataGridTextBoxColumn::Format, but it seems
you
have to do some things manually and need code here also, maybe more than for
my
brute-force-implementation.

In this case i only need to read the table. I've heard that there are still
much problems
writing back a datatable into Foxpro via OleDbCommandBuilder and
OleDataAdapter ?

Thankful greets
Sascha
 
Hi Sascha,

I've worked with it some and it's done everything I wanted to do, but then
again I've never worked with some of the less used data types like the Char
Binary that's in your table.
 
Back
Top