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

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  onde esta o erro?
vander.com
INDAIATUBA
SP - BRASIL
ENUNCIADA !
Postada em 02/09/2008 19:25 hs            
'o que tem de errado nesta programação?
'quando faço a consulta ele acha ( ou as vezes nao acha a consulta ) e me retorna -1
'estou usando o mysql e sou novato em mysql
'o access tinha o indexador ou reparador... e onde faço isso no mysql?
If (txt_codigo_usuario <> "") Then
    Set tbUser = New ADODB.Recordset
    tbUser.Open "Select * from usuario where codigo_usuario = '" & txt_codigo_usuario.Text & "'", cn, adOpenStatic, adLockOptimistic
    If (tbUser.RecordCount = 0) Then
        vPergunta = MsgBox("Deseja realmente excluir o registro?", vbQuestion + vbYesNo, "Pergunta")
        If (vPergunta = vbYes) Then
            tbUser.Delete
        End If
    End If
    tbUser.Close
    Limpar_Form_Usuario
End If
ado_usuario.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=winner"
ado_usuario.Refresh
dbg_usuario.Refresh
   
Treze
Pontos: 2843 Pontos: 2843
SÃO VICENTE
SP - BRASIL
ENUNCIADA !
Postada em 02/09/2008 23:44 hs            
Primeiro se está usando o MySQL então deve primeiro saber o seguinte:
 
se o campo for tipo integer então não deve utilizar aspas simples
 
tbUser.Open "Select * from usuario where codigo_usuario = " & txt_codigo_usuario.Text , cn,  adOpenStatic, adLockOptimistic
 
utilize aspas simples somente se o campo for tipo char ou varchar
 
o recordcount não funcionará com o ADO
 
porém não entendi esta questão
 
If (tbUser.RecordCount = 0) Then ' se não houver registros no banco fazer a pergunta?
        vPergunta = MsgBox("Deseja realmente excluir o registro?", vbQuestion + vbYesNo, "Pergunta")
        If (vPergunta = vbYes) Then
            tbUser.Delete
        End If
    End If
 
não deveria ser algo + ou - assim
 
IF tbUser.RecordCount<>0 then ' Enquanto o campo conter registros fazer a pergunta.
vPergunta = MsgBox("Deseja realmente excluir o registro?", vbQuestion + vbYesNo, "Pergunta")
        If (vPergunta = vbYes) Then
            tbUser.Delete
        End If
End If
 
porém como dito anteriormente não irá funcionar, mas poderá substiruir pelo seguinte:
 
IF tbUser.EOF = true and tbUser.BOF = true then
Exit Sub
Else
vPergunta = MsgBox("Deseja realmente excluir o registro?", vbQuestion + vbYesNo, "Pergunta")
        If (vPergunta = vbYes) Then
            tbUser.Delete
        End If
End If
 
Bom faça um teste com as alterações surgeridas e veja se, retorna o resultado esperado.
 
 
   
Alexandre Patos
Pontos: 2843 Pontos: 2843
PATOS DE MINAS
MG - BRASIL
Postada em 03/09/2008 07:38 hs            
vander, ao inves de abrir o recordset como statico , tente abrilo como dynamico
 
tbUser.Open "Select * from usuario where codigo_usuario = " & txt_codigo_usuario.Text , cn,  adOpenDynamic, adLockOptimistic
     
Página(s): 1/1    


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

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

HTML DESLIGADO

     
 VOLTAR

  



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