An issue with .NET and NPGSQL

By ronivered ·
Dear forum members,

I was wondering if you could assist me in the following issue, or at least give a direction for further inquiry for answers.

We're trying to use PostgreSQL DB and implemented Npgsql in order to connect to .NET.

The user guide:

We have no issues when inserting English data through the .NET, but from some reason, when we try to insert German data via .NET, we enter the catch block - exception with the following error message:
"Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack"

Please note that if we enter the insert command with the German query directly to the PostgreSQL, there's no error, and we can see the data in the DB with no issues.
It appears only when using the Npgsql provider.

The code is the following (I pasted a summary of it):

string sSqlCommand = "INSERT INTO query_new VALUES ( nextval('sq_newid')," + dataReposit.SID + ",'" + dataReposit.Host + "," + "'" + sSqlText + "'" + ",'" + dataReposit.StartTime.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat) + "' );";

sSqlCommand = sSqlCommand.Replace("\0", string.Empty);
sSqlCommand = sSqlCommand.Replace("\\", "\\\\");

command.CommandText = Encoding.Default.GetString(Encoding.Default.GetBytes(sSqlCommand));

// command.CommandText =
command.CommandType = System.Data.CommandType.Text;
command.Connection = conn;
iExecute = command.ExecuteNonQuery();
if (iExecute <= 0) GlobalStaticMethods.LogMessageLiron
"PostReportReaderWriter::InsertRepoQuery - > - Execute error ");
catch (NpgsqlException ex)

Can you please help me understanding why the error appears?
We tried a few different version of the Npgsql.
We tried installing PostgreSQL in German, and changing the regional settings in the O/S.
We tried changing the Encoding from UTF8 to other encodings.

It's a bit hard to search for this error message, as this isn't a Database error at all.

I would appreciate any lead.
Thanks in advance,

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums