4
When I try to make a DELETE
the following message is appearing:
My code:
private void BtnExcluir_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Confirma a Exclusão desses Registros?", "Atenção",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
conexao.ConnectionString = strconexao;
cmd.Connection = conexao;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "DELETE FROM PRODUTOS WHERE CODPROD =Codigo";
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@Codigo", chaveID);
try
{
conexao.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Registros Excluidos com Sucesso!!!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Atenção");
}
finally
{
if (conexao.State == ConnectionState.Open)
{
conexao.Close();
MontarLista();
LimparFormulario();
BtnExcluir.Enabled = true;
}
}
}
}
You can edit your question and put the code that makes this operation?
– Leonel Sanches da Silva
Sorry I can’t post right here yet
– Rennan