Bergalho 3 Posted December 4, 2016 Boas . Tenho um trabalho aqui que não está a funcionar na perfeição , é um género de registo incluindo uma base de dados criada no microsoft access que não atualiza mediante os dados inseridos no programa . Desde já mando aí o código : Public Class frmPrincipal Dim identificador As Integer = 1 Private Sub frmPrincipal_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.PessoaTableAdapter.Fill(Me.RegistoDataSet.Pessoa) End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click PessoaBindingSource.MoveNext() End Sub Private Sub butAnterior_Click(sender As Object, e As EventArgs) Handles butAnterior.Click PessoaBindingSource.MovePrevious() End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click txtNome.Clear() txtIdade.Clear() identificador = 0 txtNome.Focus() End Sub Private Sub butOk_Click(sender As Object, e As EventArgs) Handles butOk.Click Try If (identificador = 0) Then PessoaTableAdapter.PessoaInsertQuery(txtNome.Text, Integer.Parse(txtIdade.Text)) Else Dim linha As RegistoDataSet.PessoaRow = RegistoDataSet.Pessoa.Rows(PessoaBindingSource.Position) Dim código As Integer = linha.Código PessoaTableAdapter.PessoaUpdateQuery(txtNome.Text, Integer.Parse(txtIdade.Text), código) End If Catch excep As DataException MessageBox.Show(excep.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End Try identificador = 1 Me.PessoaTableAdapter.Fill(RegistoDataSet.Pessoa) End Sub Private Sub butApagar_Click(sender As Object, e As EventArgs) Handles butApagar.Click Try Dim linha As RegistoDataSet.PessoaRow = RegistoDataSet.Pessoa.Rows(PessoaBindingSource.Position) Dim código As Integer = linha.Código PessoaTableAdapter.PessoaDeleteQuery(código) Catch excep As DataException MessageBox.Show(excep.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End Try identificador = 1 Me.PessoaTableAdapter.Fill(RegistoDataSet.Pessoa) End Sub End Class Share this post Link to post Share on other sites