1
When I enter letter in txtIdade, the program should return the exception message. But does not return, Visual Studio informs that there is exception without treatment.
try
{
var conn = new OracleConnection(ConfigurationManager.AppSettings["strConexao"]);
var comm = new OracleCommand($"insert into Nome(nome,idade,endereco) values ('{txtNome.Text}','{txtIdade.Text}','{txtEndereco.Text}')", conn);
conn.Open();
var reader = comm.ExecuteNonQuery();
read();
}
catch (FormatException ex)
{
MessageBox.Show(ex.Message, "erro");
return;
}
Do it the right way (https://answall.com/q/293843/101) and you won’t have this problem. You may have another problem, but you won’t have that one. This code is absolutely unsafe.
– Maniero
It must be because another error is happening, try putting only Exception to see which error will shoot, because he is the father of all exceptions.
– Kevin Sampaio
Thanks for the answers! I changed and I worked here! I didn’t even know I was insecure, I’m at the beginning yet..
– Vinícius Malon
@Viníciusmalon Then post a reply with the changes you made that have solved your problem.
– Leandro Angelo