Jump to content

Apagar e inserir novos valores numa bd


imilka
 Share

Recommended Posts

Quando faço o "arranque" do programa e apago valores que estao na base de dados, quando insiriro novos dá-me este erro

"Update requer um DeleteCommand válido quando transferir a colecção DataRow com linhas eliminadas."

O qué? e como se resolve?

Link to comment
Share on other sites

eu ja tinha criado um topico com problemas neste programa, por isso não estranhem que o código seja parecido.

 
public Form1()
        {
            InitializeComponent();
        }

        private void testeBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.testeBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.database1DataSet1);

        }
       

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'database1DataSet1.teste' table. You can move, or remove it, as needed.
            this.testeTableAdapter.Fill(this.database1DataSet1.teste);
            testeBindingNavigator.AddNewItem.PerformClick();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "txt(*.txt)|*.txt|pdf(*.pdf)|*.pdf|docx(*.docx)|*.docx|*.*(*.*)|*.*";
            openFileDialog1.FileName = "";
            openFileDialog1.ShowDialog();
            testeTextBox.Text = (openFileDialog1.FileName);

            webBrowser1.Navigate(testeTextBox.Text);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            testeBindingNavigator.AddNewItem.PerformClick();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            testeBindingNavigatorSaveItem.PerformClick();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            testeBindingNavigator.DeleteItem.PerformClick();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        
    }
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.