MikeyRoberts
2006-10-26 07:32:35 UTC
Hi All,
I am working with a legacy application that uses Foxpro .dbf files for
some of its data storage. I am writing a new .net datalayer and I am
connecting to the .dbf files using the Foxpro OLEDB driver version 9
SP1.
One of the character fields in the DB uses characters with an
underlying byte value outside of the standard ASCII character set (eg
A0,D4).
The problem I am having is that the OLEDB driver is encoding the
characters within this field using codepage 850(multilingual DOS) and
providing the wrong characters in my .net dataset. Instead of bytes
values for my characters of A0,D4,D0 etc I am getting A3, CE, 2B etc.
This is complicated by the fact that I am observing the values of the
returned characters within windows, and I'm not sure if there is also a
codepage conversion happening to encode the characters to the Windows
Default encoding.
I have confirmed that it is a codepage issue with the OLEDB driver and
the .dbf file by editing the codepage flage (byte 29) in the .dbf.
Setting this to 00 or 03(codepage 1252) means that the characters are
returned exactly how I was expecting them. However, there doesn't seem
to be a way to set up the OLEDB driver to ignore the codepage flag in
the file. I have tried setting the locale identifier in the connection
string, but this didn't help.
So, in summary, here is the problem:
- I can not permanently change the codepage flag in the file as it may
have some effect in the legacy application.
- I can not use the CPCONVERT function as it is not supported from
within SQL queries in the OLEDB (only in Stored Procs)
- I can not see anyway to set up the OLEDB driver to ignore the
codepage flag in the .dbf
- I am currently only using free table access to the .dbf tables - a
.dbc might be a possibility, but I do not have access to Foxpro
I have a couple of thoughts of how I may approach this problem:
- Use ADOX to create a .dbc and add a stored proc to this .dbc to
extract the data, using CPCONVERT to extract the field data (this is
tricky - how do I create a stored proc for Foxpro in ADOX???)
- Find some way to reverse the codepage encodings that have been
applied to my string data to get the the original values
- Before executing my query, open the .dbf file as a byte stream and
reset the codepage flag (what a lovely Kludge!), remembering to set
this back when my query has finished - oh, and ignore any file locking
problems this may cause.
This issue has been driving me mad for a while now, any help would be
appreciated.
Cheers,
Mike
I am working with a legacy application that uses Foxpro .dbf files for
some of its data storage. I am writing a new .net datalayer and I am
connecting to the .dbf files using the Foxpro OLEDB driver version 9
SP1.
One of the character fields in the DB uses characters with an
underlying byte value outside of the standard ASCII character set (eg
A0,D4).
The problem I am having is that the OLEDB driver is encoding the
characters within this field using codepage 850(multilingual DOS) and
providing the wrong characters in my .net dataset. Instead of bytes
values for my characters of A0,D4,D0 etc I am getting A3, CE, 2B etc.
This is complicated by the fact that I am observing the values of the
returned characters within windows, and I'm not sure if there is also a
codepage conversion happening to encode the characters to the Windows
Default encoding.
I have confirmed that it is a codepage issue with the OLEDB driver and
the .dbf file by editing the codepage flage (byte 29) in the .dbf.
Setting this to 00 or 03(codepage 1252) means that the characters are
returned exactly how I was expecting them. However, there doesn't seem
to be a way to set up the OLEDB driver to ignore the codepage flag in
the file. I have tried setting the locale identifier in the connection
string, but this didn't help.
So, in summary, here is the problem:
- I can not permanently change the codepage flag in the file as it may
have some effect in the legacy application.
- I can not use the CPCONVERT function as it is not supported from
within SQL queries in the OLEDB (only in Stored Procs)
- I can not see anyway to set up the OLEDB driver to ignore the
codepage flag in the .dbf
- I am currently only using free table access to the .dbf tables - a
.dbc might be a possibility, but I do not have access to Foxpro
I have a couple of thoughts of how I may approach this problem:
- Use ADOX to create a .dbc and add a stored proc to this .dbc to
extract the data, using CPCONVERT to extract the field data (this is
tricky - how do I create a stored proc for Foxpro in ADOX???)
- Find some way to reverse the codepage encodings that have been
applied to my string data to get the the original values
- Before executing my query, open the .dbf file as a byte stream and
reset the codepage flag (what a lovely Kludge!), remembering to set
this back when my query has finished - oh, and ignore any file locking
problems this may cause.
This issue has been driving me mad for a while now, any help would be
appreciated.
Cheers,
Mike