2
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 making the Insert directly on the seat, it rotates perfectly
insert into actweb.usuarios (matricula, nome, senha, nivel, maleta, email) values ('TESTE', 'Frederico', 'TESTE', 1, 7000, '[email protected]');
I running directly, without using the right Parameters.
var sql = @"Insert into usuarios(id,name) values (ID_USUARIOS.nextval, 'It will work')";
Insert into actweb.usuarios (matricula, nome, password, nivel, maleta, email) values ('TESTE', 'Frederico', 'TESTE', 1, 7000, '[email protected]');
– user2254936
You should [Edit] your question to add this information. You know this
try catch finnaly
does not have any utility in your code? It is even causing problem. Theusing
is solving connection closure.– Maniero
The
catch
is swallowing the error. If you take it out, you will have some useful information to figure out where the error is. Then you can solve or post here what the error is, so it is easier to help you.– Maniero
I took the catch, now you are showing this error One or more errors occurred while processing the command. ORA-00936: expression not found
– user2254936
You need to [edit] your question to make it complete with this information and make it easy for anyone who knows Oracle errors and can help you.
– Maniero