using (var cnx = new OleDbConnection(new AdministradorDAO().conexao))
{
var sql =
@"insert into usuarios(matricula, nome, senha, nivel, maleta, email)
values (@matricula, @nome, @senha, @nivel, @maleta, @email)";
using (var cmd = new OleDbCommand(sql, cnx))
{
cnx.Open();
cmd.Parameters.AddWithValue("@matricula", txt_matricula.Text);
cmd.Parameters.AddWithValue("@nome", txt_nome.Text);
cmd.Parameters.AddWithValue("@senha", txt_senha.Text);
cmd.Parameters.AddWithValue("@nivel", DropDownList_nivel.Text);
cmd.Parameters.AddWithValue("@maleta", txt_maleta.Text);
cmd.Parameters.AddWithValue("@email", txt_email.Text);
try { cmd.ExecuteNonQuery(); }
catch { }
finally { if (cnx.State == ConnectionState.Open) cnx.Close(); }
}
}
When inserting directly into the seat, it runs perfectly
insert into actweb.usuarios (matricula, nome, senha, nivel, maleta, email) values ('TESTE', 'Frederico', 'TESTE', 1, 7000, '[email protected]');
I'm running directly, without using the right parameters.
var sql = @ "insert into users (id, name) values (ID_USUARIOS.nextval, 'Will work')";