Hi, thats me again :)

Now i m trying to delete a record using this:

int codigo=int.Parse(this.txtCli_cod.Text);
                if (dr ==DialogResult.Yes){
                        try {
                                da_cli.DeleteCommand = con.CreateCommand();
                                        da_cli.DeleteCommand.CommandText = "DELETE FROM CLIENTES WHERE
CLI_COD = @cli_cod";
                                        da_cli.DeleteCommand.Parameters.Add("@cli_cod",
codigo).SourceColumn = "CLI_COD";
                                        da_cli.Update(ds_cli, "CLIENTES");
                                        ds_cli.AcceptChanges();
                                        MessageBox.Show("Record deleted...");
                        } catch (Exception ex) {
                                MessageBox.Show(ex.ToString());
                        }
                } else {
                        MessageBox.Show("Record NOT deleted...");
                }

da_cli is my data Adapter and ds_cli is my DataSource, is something
wrong with this?

My INSERT command works, here is the code:

da_cli.InsertCommand = con.CreateCommand();
                        // DADOS:
                                da_cli.InsertCommand.CommandText = "INSERT INTO CLIENTES
(CLI_COD,CLI_NOME, CLI_SOBRENOME)
VALUES(@cli_cod,@cli_nome,@cli_sobrenome)";
                                da_cli.InsertCommand.Parameters.Add("@cli_cod",
codigo).SourceColumn = "CLI_COD";
                                da_cli.InsertCommand.Parameters.Add("@cli_nome",
txtCli_nome.Text.ToString()).SourceColumn = "CLI_NOME";
                                da_cli.InsertCommand.Parameters.Add("@cli_sobrenome",
txtCli_sobrenome.Text.ToString()).SourceColumn = "CLI_SOBRENOME";
                                da_cli.Update(ds_cli, "CLIENTES");
                                ds_cli.AcceptChanges();




The insert above works, and i cant figure out why the DELETE isnt
working, i already checked the codigo var, and its filled with the
correct number, but the command just won´t delete anything, and it
doesnt give me any exception.

thanx for any help.

Reply via email to