Error: Registering? in place of special character only using the browser

4

I'm having a problem saving data in my ORACLE database.

When using my application to fill in fields and register a string, special characters such as accents are replaced by a ? in the database

The detail is that if I get the same query and I do through SQL DEVELOPER it usually registers any special characters.

My application is made in C #, with pages using Razor (cshtml). The html charset is UTF-8.

I do not know how to check the charset of the bank, as I am very new to ORACLE.

Ideas about what might be causing this?

In-app code:

comand.CommandText = "UPDATE TB_EBITDA SET TXT_OBSERVACAO = '" + txt_observacao + "' WHERE COD_CONFIGURACAO = " + codigo + "";
dataReader = comand.ExecuteReader();
dataReader.Read();

Generated code, I got through the debug and pasted it into SQL Developer:

UPDATE TB_EBITDA SET TXT_OBSERVACAO = 'Observacão' WHERE COD_CONFIGURACAO = 5
    
asked by anonymous 18.03.2014 / 21:33

1 answer

2

Apparently the problem is in the (lack of) parameterization of its sentence. Without this parameterization, there is no guarantee that you are executing a statement adhering to the Unicode standard.

I would write your code as follows:

comand.CommandText = "UPDATE TB_EBITDA SET TXT_OBSERVACAO = :txt_observacao WHERE COD_CONFIGURACAO = " + codigo + "";

IDbDataParameter param = comand.CreateParameter()
param.DbType = DbType.AnsiString;
param.ParameterName = "txt_observacao";
param.Value = txt_observacao;

comand.Parameters.Add(param);
dataReader = comand.ExecuteReader();
dataReader.Read();
    
18.03.2014 / 22:26