Problem using swedish special characters

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Guest

Problem using swedish special characters

Post by Guest » Thu 02 Feb 2006 22:42

Hi,

I've been using your product for awhile now and it
has worked like a charm. However, I've stumbled upon
something that I think may be caused by the PostgreSQLDirect.Net
data provider.

I am storing swedish characters åäöÅÄÖ (HTML codes: åäöÅÄÖ) in the PostgreSQL
database. No problem thus far. I am using UTF8 encoding and the latest Postgre version.

But when I am trying to retrive data from the database the characters gets scrambled into something else. And if I try and save a row into the database that contains these characters I get the following error:

[error]
invalid UTF-8 byte sequence detected near byte 0xe5

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: CoreLab.PostgreSql.PgSqlException: invalid UTF-8 byte sequence detected near byte 0xe5

Source Error:
Line 52: PgSqlDataReader dr = command.ExecuteReader();
[/error]

Is there a known problem with using swedish characters with the PostgreSQLDirect.NET data provider or am I doing something wrong?

In the asp.net web.config file I have utf8 encoding specified so there shouldn't be any problems.


Help is highly appreciated!

Kind Regards,
Robert Blixt

SecureGen
Devart Team
Posts: 133
Joined: Thu 08 Sep 2005 06:27

Post by SecureGen » Fri 03 Feb 2006 08:11

This error message is returned by Postgre SQL server when you try to insert such values.
Can you insert/select these characters in PgAdmin?

Please try to use DBMonitor tool for monitoring all statements between client and server. Try to insert data that contains such symbols and check SQL statement and actual parameter values in DbMonitor.

diod
Posts: 6
Joined: Thu 02 Feb 2006 22:31
Location: Sweden
Contact:

Post by diod » Fri 03 Feb 2006 08:24

Yes I have tried it within PgAdmin and it worked fine using the
exact same sql statements.

I have not tried the DBMonitor tool, I will take a look at it right
a way and let you know how it went.

diod
Posts: 6
Joined: Thu 02 Feb 2006 22:31
Location: Sweden
Contact:

Post by diod » Fri 03 Feb 2006 17:28

I'm having some trouble getting DMBonitor to work. I see
the Devend.exe process and it tells me that monitoring is
started but I get no more information.

Hopefully I'll have it solved soon enough. Is there a specific
way to add the PgsqlMonitor class to an asp.net webb-application?


Kind Regards,
Robert

diod
Posts: 6
Joined: Thu 02 Feb 2006 22:31
Location: Sweden
Contact:

Post by diod » Mon 06 Feb 2006 08:03

Still can't get DBMonitor to work.

I decided to set it up on another machine, and
I managed to get the DBMonitor to work there
with no problem at all. And of course, swedish
characters worked as they should on that machine.

This is getting annoying :-)

Is there something else I need to configure to
get the DBMonitor to work on a Win2003 Server OS?
I can get it to work on a XP Pro OS but not the 2003
Server OS.


EDIT:
If I start DBMonitor before VS.Net 2003 then it
will find the devenv.exe process. But I still can't get no
database activity in DBMonitor.



Cheers.

SecureGen
Devart Team
Posts: 133
Joined: Thu 08 Sep 2005 06:27

Post by SecureGen » Mon 06 Feb 2006 14:26

We have not tested DBMonitor on Win2003 OS. We plan this test.
You can also trace executed commands and parameters using TraceEvent of PgSqlMonitor component. You should define a handler for this event and output all parameters into console or component on the form.
private void pgSqlMonitor1_TraceEvent(object sender, CoreLab.Common.MonitorEventArgs e) {

PgSqlCommand cmd = sender as PgSqlCommand;
if (cmd != null) {
Console.WriteLine(string.Format("Command : {0}", e.Description));
Console.WriteLine("Parameters:");
foreach (PgSqlParameter param in cmd.Parameters) {
Console.WriteLine(string.Format("param name: {0} value: {1}", param.ParameterName, param.Value));
}
}
}

Since it works without problem on XP platform, then maybe on Server2003 platform you have problem with conversion to unicode somewhere before PostgreSQLDirect .NET Data Provider.

Please also clarify, which platform do you use, 32 or 64 bit?

SecureGen
Devart Team
Posts: 133
Joined: Thu 08 Sep 2005 06:27

Post by SecureGen » Mon 06 Feb 2006 15:45

We have fixed this problem for the PostgreSQLDirect .NET.
Look forward for the next build.

diod
Posts: 6
Joined: Thu 02 Feb 2006 22:31
Location: Sweden
Contact:

Post by diod » Tue 07 Feb 2006 07:13

Ah, great news. Thank you for your quick reply and help.
I am using the 32Bit version by the way.

Kind Regards,
Robert

diod
Posts: 6
Joined: Thu 02 Feb 2006 22:31
Location: Sweden
Contact:

Post by diod » Mon 06 Mar 2006 12:25

I downloaded the new version 2.50, but I still
get the same error.

In the previous post how do I use the pgSqlMonitor1_TraceEvent,
and how do I define an event handler within my
asp.net webforms project?

SecureGen
Devart Team
Posts: 133
Joined: Thu 08 Sep 2005 06:27

Post by SecureGen » Mon 06 Mar 2006 12:54

You can use pgSqlMonitor1_TraceEvent in the same way, outputting data to a file.

diod
Posts: 6
Joined: Thu 02 Feb 2006 22:31
Location: Sweden
Contact:

Post by diod » Tue 07 Mar 2006 11:56

Ok, outputting to a file is no problem. But how
do I use the traceevent method.. I haven't done
any event management earlier.

SecureGen
Devart Team
Posts: 133
Joined: Thu 08 Sep 2005 06:27

Post by SecureGen » Tue 07 Mar 2006 12:28

The following sample shows how to enable and disable monitoring of database activity in your application.

Code: Select all

static void OnEvent(object sender, MonitorEventArgs e) 
{ 
  if (e.TracePoint==MonitorTracePoint.BeforeEvent) 
  { 
    Console.WriteLine("Description: " + e.Description); 
    Console.WriteLine(" Extra info: " + e.ExtraInfo); 
  } 
} 
 
 
[MTAThread] 
static void Main(string[] args) 
{ 
  PgSqlConnection pgConn = new PgSqlConnection(host=server;database=test;user id=postgres); 
  PgSqlMonitor pgMonitor = new PgSqlMonitor(); 
  pgMonitor.TraceEvent += new MonitorEventHandler(OnEvent); // <-- Pay attention to this line 
  pgMonitor.IsActive = true; 
  PgSqlCommand pgCommand = new PgSqlCommand("select count(*) from dept",pgConn); 
  pgConn.Open(); 
  Console.WriteLine(pgCommand.ExecuteScalar()); 
  pgConn.Close(); 
  pgMonitor.TraceEvent -= new MonitorEventHandler(OnEvent); 
  Console.ReadLine(); 
} 

Post Reply