Problem using swedish special characters
Problem using swedish special characters
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
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
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.
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.
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
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
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.
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.
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?
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?
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();
}