USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  ALTERAR E EXCLUIR REGISTROS
Luiz
não registrado
Postada em 31/01/2006 09:14 hs   

Olá,

 

  Eu uso os metodos ADDNEW, EDIT e DELETE para incluir, alterar e excluir registros numa tabela ACCESS (cfe. Abaixo). Estou querendo mudar para instruções SQL (INSERT, UPDATE e DELETE). Será que alguem poderia me mostrar como ficariam os codigos abaixo para ALTERAR e DELETAR usando instruções SQL (o metodo INSERT eu já consegui fazer). Obrigado.

 

 

ALTERAR:

     SQL = "SELECT * FROM agenda WHERE codigo=" & CInt(gridagenda.Text) & “”

Rs.edit

Rs(“codigo”) = txtcodigo

Rs(“data”) = txtdata

Rs(“hora”) = txthora

Rs(“evento”) = txtevento

Rs.update

 

EXCLUIR:

SQL = "SELECT * FROM agenda WHERE codigo = " & CLng(gridagenda.Text) & ""

Rs.delete

     
MARCONE
Pontos: 2843
BRASÍLIA
DF - BRASIL
Postada em 31/01/2006 09:36 hs            
USANDO ADO:
 
ALTERAR:
sSql = "UPDATE agenda SET "
sSql = sSql & "codigo= '" & txtcodigo & "'"
sSql = sSql & ", data = '" & txtdata & "'"
sSql = sSql & ", hora = '" & txthora & "'"
sSql = sSql & ", evento = '" & txtevento & "'"
sSql = sSql & "WHERE codigo=" & CInt(gridagenda.Text)SuaConexao.Execute sSql
 
'-----------------------------------------------------
 

EXCLUIR:

SQL = "DELETE * FROM agenda WHERE codigo = " & CLng(gridagenda.Text) & ""

SuaConexao.Execute sSql


MarconeEmoções

 

     
Daniel
Pontos: 2843
SÃO PAULO
SP - BRASIL
Postada em 31/01/2006 09:44 hs            
estou supondo que codigo seja numérico, e evento seja texto
Inserir:
INSERT INTO Agenda ( codigo, data, hora, evento )
SELECT " & txtcodigo & " AS Expr1, " & CDate(txtdata) & " AS Expr2, " & Hour(txthora) & " AS Expr3, '" & txtevento & "' AS Expr4;
 
Alterar
UPDATE Agenda SET Agenda.codigo = " & txtcodigo & ", Agenda.data = " & CDate(txtdata) & ", Agenda.hora = " & Hour(txthora) & ", Agenda.evento = '" & txtevento & "';
 
Excluir:
DELETE Agenda.codigo
FROM Agenda
WHERE (((Agenda.codigo)=" & CLng(gridagenda.Text) & "));



dsmn
     
Luiz
não registrado
Postada em 01/02/2006 11:44 hs   
Valeu Daniel e Marcone. Usei as dicas de voces e consegui.
 
Luiz 
     
Página(s): 1/1    


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2025   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página