Recent

Author Topic: Display of non UTF charset in DBGrid using OracleConnection  (Read 48720 times)

salog

  • Newbie
  • Posts: 2
Display of non UTF charset in DBGrid using OracleConnection
« on: November 19, 2008, 09:03:39 am »
I connect to Oracle database with OracleConnection component, and use SQLQuery to get data from the server. The oracle server works in WIN-1251 charset.
The SQLQuery works properly, but fields containing russian charasters are displayed in a DBGrid empty.

How can I resolve this problem?

salog

  • Newbie
  • Posts: 2
RE: Display of non UTF charset in DBGrid using OracleConnect
« Reply #1 on: November 21, 2008, 02:05:29 am »
More over, I tryed to convert WIN1251 to UTF in GetText procedure of the field.
So, I have defined, that the value of this field is empty just its' got from the database.
It means that Russian characters are lost when they are being retrieved from the Oracle. - somewhere in deeper levels of the database component's code.

Are developers going to add transliteration features to newer versions of Lazarus? :-(

tatamata

  • Hero Member
  • *****
  • Posts: 787
    • ZMSQL - SQL enhanced in-memory database
Display of non UTF charset in DBGrid using OracleConnection
« Reply #2 on: November 23, 2008, 12:52:17 pm »
Hi!
It is simple.
Iterate through you dataset rows, then through every field. Inspect every field whether field type is String, if yes then Dataset1.FieldByName('YourField').AsSring:=AnstiToUTF8(Dataset1.FieldByName('YourField').AsSring);

jesusr

  • Sr. Member
  • ****
  • Posts: 484
Display of non UTF charset in DBGrid using OracleConnection
« Reply #3 on: November 24, 2008, 04:25:38 pm »
When using firebird one can set the "connection" charset property to UTF8 so even when data is stored in some other encoding, the DB engine will do conversions on the fly to UTF8 which is what Lazarus expect.

Try to research what charset value works for you, also, it seems Oracle client library can be configured to some specific encoding, some way, as I don't use Oracle I don't know the details though.

net_goose

  • New Member
  • *
  • Posts: 23
Display of non UTF charset in DBGrid using OracleConnection
« Reply #4 on: March 19, 2010, 10:17:45 am »
Please? reply about this topic:
"Are developers going to add transliteration features to newer versions of Lazarus?"

Zoran

  • Hero Member
  • *****
  • Posts: 1831
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Display of non UTF charset in DBGrid using OracleConnection
« Reply #5 on: March 19, 2010, 12:08:30 pm »
Please? reply about this topic:
"Are developers going to add transliteration features to newer versions of Lazarus?"

Use LConvEncoding unit. There are functions for converting between different charsets.

Or you mean something else by "transliteration features"?

net_goose

  • New Member
  • *
  • Posts: 23
Re: Display of non UTF charset in DBGrid using OracleConnection
« Reply #6 on: March 23, 2010, 08:24:44 am »
'll Show how it will affect in DBGRID. If you can please give an example!

net_goose

  • New Member
  • *
  • Posts: 23
Re: Display of non UTF charset in DBGrid using OracleConnection
« Reply #7 on: March 23, 2010, 08:36:06 am »
How to display in the correct dbgrid Russian font

Zoran

  • Hero Member
  • *****
  • Posts: 1831
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Display of non UTF charset in DBGrid using OracleConnection
« Reply #8 on: March 23, 2010, 08:57:04 am »
How to display in the correct dbgrid Russian font

Which database do you use?

net_goose

  • New Member
  • *
  • Posts: 23
Re: Display of non UTF charset in DBGrid using OracleConnection
« Reply #9 on: March 23, 2010, 09:52:56 am »
oracle 10g on linux server. application (lazarus project) on windows xp.
when i open recordset the dbgrid display ???-20 instead (УВК-20)
« Last Edit: March 23, 2010, 09:56:25 am by net_goose »

Zoran

  • Hero Member
  • *****
  • Posts: 1831
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Display of non UTF charset in DBGrid using OracleConnection
« Reply #10 on: March 24, 2010, 08:30:52 am »
oracle 10g on linux server. application (lazarus project) on windows xp.
when i open recordset the dbgrid display ???-20 instead (УВК-20)

I can't test it with oracle now, but here is what I think might solve the problem.
If you use ZEOS, try putting this line in ZConnection's "properties" property:
(If you use SQLdb, you might try to add the line in OracleConnection's params property or perhaps SQLTransaction's params property...)

Code: [Select]
codepage=UTF8
Or perhaps it should be for you:

Code: [Select]
codepage=WIN1251
Try both of these (not both at same time).
« Last Edit: March 24, 2010, 08:36:28 am by Zoran »

net_goose

  • New Member
  • *
  • Posts: 23
Re: Display of non UTF charset in DBGrid using OracleConnection
« Reply #11 on: March 24, 2010, 08:56:38 am »
I tried, and was surprised I enter data into params OracleConnections, click OK, open again, and the value of lost that. It may be?

I used your advice but, unfortunately, did not help.
I tried to use the ODAC with direct access to ORACLE, but this property is not available, but using Dephi7 no problems with the encoding but I have not changed anything in the parameters of the connection  :'(

I think that the problem until it is in lazarus, sorry but I will wait for the decision!
« Last Edit: March 24, 2010, 09:02:26 am by net_goose »

Zoran

  • Hero Member
  • *****
  • Posts: 1831
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Display of non UTF charset in DBGrid using OracleConnection
« Reply #12 on: March 24, 2010, 09:14:21 am »
I used your advice but, unfortunately, did not help.
I tried to use the ODAC with direct access to ORACLE, but this property is not available, but using Dephi7 no problems with the encoding but I have not changed anything in the parameters of the connection  :'(

I think that the problem until it is in lazarus, sorry but I will wait for the decision!

I'm sorry, I can't do tests with oracle...
I don't think that it has anything to do with DBGrid, the problem seems to be burried deeper.
It would be nice that DB components developers join this discussion...

As a start, try testing with ZEOS components.

net_goose

  • New Member
  • *
  • Posts: 23
Re: Display of non UTF charset in DBGrid using OracleConnection
« Reply #13 on: March 24, 2010, 02:13:06 pm »
I installed zeos 6.6.6, same result.

Maybe the problem in the versions, I use Lazarus 0.9.28.2-fpc 2.2.4 and Zeos 6.6.6

Zoran

  • Hero Member
  • *****
  • Posts: 1831
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Display of non UTF charset in DBGrid using OracleConnection
« Reply #14 on: March 24, 2010, 02:33:24 pm »
I installed zeos 6.6.6, same result.

Maybe the problem in the versions, I use Lazarus 0.9.28.2-fpc 2.2.4 and Zeos 6.6.6

No, I don't think so...
I'm wandering... is it perhaps a font problem? Did you set the DBGrid's font explicitely? Are you sure that the used font can display cirilic? Set the font to some for which you are sure.

 

TinyPortal © 2005-2018