Question

Locked

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:
http://npgsql.projects.postgresql.org/docs/manual/UserManual.html

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 =
UTF8Encoding.Default.GetString(UTF8Encoding.Default.GetBytes(sSqlCommand));
command.CommandType = System.Data.CommandType.Text;
command.Connection = conn;
try
{
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,
AshkA

This conversation is currently closed to new comments.

0 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Windows Forum
0 total posts (Page 1 of 1)  

Related Discussions

Related Forums