aprendiz93 Posted January 9, 2012 at 10:39 AM Report #431008 Posted January 9, 2012 at 10:39 AM Bom dia pessoal. Gostaria de saber como faço para eliminar um determinado registro no bd access.? Sei como fazer para eliminar todos os registros no bd, mais n quero isso, quero q elimine somente o registro que a pessoa quiser. Tenho um datagridview mostrando todos os registros no bd, gostaria que a pessoa pudesse clicar no botao de excluir e poder escolher qual registro eliminar. Gostaria de saber tb como faço para alterar os registros do bd acces. Agradeço desde já pela atenção.
obamaself Posted January 9, 2012 at 10:49 AM Report #431015 Posted January 9, 2012 at 10:49 AM qual e o codigo que usas para eliminar todos? se as qwery s do acess forem igual as do SQL, é assim: Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click 'No objecto inseres esta qwery e ele elimina o respectivo registo que selecciona Dim sSql As String = "Delete from tabela1 where codigo='" & datagridview1.Item(datagridview1.CurrentCell.ColumnIndex, dgdatagridview1CurrentCell.RowIndex).Value & "'" end sub
aprendiz93 Posted January 9, 2012 at 11:39 AM Author Report #431031 Posted January 9, 2012 at 11:39 AM Estou utilizando este código: Dim ligação As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Visual Studio 2008\Projects\Pagar.accdb;Persist Security Info=False;" Dim conecção As New OleDbConnection(ligação) Dim sintaxe As String = "DELETE FROM Pagar"
obamaself Posted January 9, 2012 at 12:10 PM Report #431038 Posted January 9, 2012 at 12:10 PM Na variavel sintaxe, para eliminar apenas um pões : "Delete from PAGAR where codigo='" & datagridview1.Item(0, dgdatagridview1CurrentCell.RowIndex).Value & "'" mandas como parametro o codigo que o utilizador escolheu, neste caso eu pus que na coluna 0 da datagridview estão os codigos ( chaves primarias)
aprendiz93 Posted January 9, 2012 at 12:53 PM Author Report #431050 Posted January 9, 2012 at 12:53 PM esta dando erro
Caça Posted January 9, 2012 at 01:05 PM Report #431051 Posted January 9, 2012 at 01:05 PM Que erro? Pedro Martins Não respondo a duvidas por PM
aprendiz93 Posted January 9, 2012 at 01:37 PM Author Report #431059 Posted January 9, 2012 at 01:37 PM Error 1 Overload resolution failed because no accessible 'Item' can be called with these arguments: Public Default Property Item(columnName As String, rowIndex As Integer) As System.Windows.Forms.DataGridViewCell Public Default Property Item(columnIndex As Integer, rowIndex As Integer) As System.Windows.Forms.DataGridViewCell C:\Users\Documents\Visual Studio 2008\Projects\Form4.vb
obamaself Posted January 9, 2012 at 01:48 PM Report #431063 Posted January 9, 2012 at 01:48 PM Dentro do evento da datagridview "cellclick" é que chamas a função.
bioshock Posted January 9, 2012 at 01:51 PM Report #431065 Posted January 9, 2012 at 01:51 PM https://wiki.portugal-a-programar.pt/dev_net/vb.net/access/
aprendiz93 Posted January 16, 2012 at 06:09 PM Author Report #432818 Posted January 16, 2012 at 06:09 PM Opa amigo neste link so mostra como excluir todos os registro. n um especificado. eu gostaria de saber como faço para Alterar um registro no DatagridView e como excluir registro especificado no DatagridView.
bioshock Posted January 16, 2012 at 06:12 PM Report #432819 Posted January 16, 2012 at 06:12 PM Ai não mostra? Ora vê lá novamente com olhos de ver..
aprendiz93 Posted January 16, 2012 at 06:30 PM Author Report #432827 Posted January 16, 2012 at 06:30 PM hm.. tendeu.. agora consegui. so q o duro q a pessoa precisa colocar o codigo na textbox e depois clicar no botao excluir. Seria melhor fazer um esquema, de quando a pessoa clicar no botao excluir ai desse uma mensagem pedindo para ela colocar o codigo desejado. Terei q colocar um aviso. para excluir um regitro e preciso colocar o codigo no campo tal e depois clicar no botao excluir. Agradeço pela força Abçs
bioshock Posted January 16, 2012 at 06:35 PM Report #432830 Posted January 16, 2012 at 06:35 PM Que complicação que estás a fazer. No artigo tem isto: command.Parameters.Add("@IDCliente", OleDbType.Integer).Value = IDClienteTextbox.Text Onde, como disseste, vai eliminar o Cliente que está na Textbox, mas se tu não tens nenhuma Textbox, se é à base de células que estás a trabalhar, podes apontar para a célula: command.Parameters.Add("@IDCliente", OleDbType.Integer).Value = DataGridView1.Rows(0).Cells(0).Value
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now