473,326 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Foxpro & Unicode

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

Nov 16 '05 #1
7 7274
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]
- mv*@spam.guard.caspershouse.com

"Sascha Schmidt" <Sa****@nospam.de> wrote in message
news:cv**********@mail.lachmann-rink.de...
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
Nov 16 '05 #2
Just to add, the latest FoxPro and Visual FoxPro OLE DB data provider is
downloadable from http://msdn.microsoft.com/vfoxpro/downloads/updates/ . It
will work with all versions of FoxPro tables and DBC's.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
ci**************@msn.com www.cindywinegarden.com
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uh**************@TK2MSFTNGP14.phx.gbl...
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.

Nov 16 '05 #3
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

Nov 16 '05 #4
Hi Sascha,

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

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
ci**************@msn.com www.cindywinegarden.com
"Sascha Schmidt" <Sa****@nospam.de> wrote in message
news:cv**********@mail.lachmann-rink.de...
Maybe i can send it to an email address? (The zip-file's size is about 109
kB,
quite small).

Nov 16 '05 #5
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.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
ci**************@msn.com www.cindywinegarden.com
Nov 16 '05 #6
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

"Cindy Winegarden" <ci**************@msn.com> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
ci**************@msn.com www.cindywinegarden.com

Nov 16 '05 #7
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.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
ci**************@msn.com www.cindywinegarden.com
"Sascha Schmidt" <Sa****@nospam.de> wrote in message
news:cv**********@mail.lachmann-rink.de...
...I've heard that there are still
much problems
writing back a datatable into Foxpro via OleDbCommandBuilder and
OleDataAdapter ?

Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gandhi | last post by:
Hi all, I've noticed that using xmlrpc_encode() (php built-in function) changes the encoding of data (to unicode, it seems). Is there a way to prevent this, so that xmlrpc_encode doesn't alter the...
23
by: Michel Claveau - abstraction méta-galactique non | last post by:
Hi ! If Python is Ok with Unicode, why the next script not run ? # -*- coding: utf-8 -*- def режим(toto): return(toto*3)
3
by: anthony hornby | last post by:
Hi, I am starting my honours degree project and part of it is going to be manipulating ASCII encoded XML files from a legacy database and converting them to Unicode and doing text processing stuff...
27
by: EU citizen | last post by:
Do web pages have to be created in unicode in order to use UTF-8 encoding? If so, can anyone name a free application which I can use under Windows 98 to create web pages?
0
by: Marcel Jalbert | last post by:
Hartford Connecticut area Fortune 500 Financial Services Company is looking for several experienced FoxPro and Visual Basic DotNet programmers. 10 Years FoxPro and 3 Years VB DotNet experience...
0
by: Pavel aka crazy | last post by:
hi, all! how can i use unicode in postgresql tables? "createdb -E UNICODE dbname" work correctly, but when i put data and then read it i see only garbage instead cyrillic letters. what i do wrong?...
3
by: KvS | last post by:
Hi all, I've been reading about unicode in general and using it in Python in particular lately as this turns out to be not so straightforward actually. I wanted to aks two questions: 1) I'm...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.