Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/05/2013, 19:06
Avatar de elvaleehdj
elvaleehdj
 
Fecha de Ingreso: julio-2011
Mensajes: 33
Antigüedad: 12 años, 9 meses
Puntos: 0
Escribir registros en la base de datos y validar

Hola gente, como estan?

Estoy recien empezando en el mundo de Vb 6 y queria saber como puedo hacer para que cuando escriba en la base de datos acces (2007), antes compruebe si existe algun registro con el mismo nombre..

Acá dejo mi codigo..
Código:
Option Explicit

Private Sub Command1_Click()
Set Data1 = New ADODB.Connection
    With Data1
        .Provider = "Microsoft.ACE.OLEDB.12.0"
        .ConnectionString = "Data Source = " & App.Path & "\agenda.accdb"
        .Open
    End With
    
'-----------------------------------------------------------------------------------------------------------------------------

If nombreagr.Text = "" Then MsgBox "Ingrese usuario", vbInformation, "ERROR": nombreagr.SetFocus: Exit Sub
If passagr.Text = "" Then MsgBox "Ingrese la contraseña", vbInformation, "ERROR": passagr.SetFocus: Exit Sub

'-----------------------------------------------------------------------------------------------------------------------------

Data1.Execute "Insert into Usuarios(Id, Pass) Values('" & nombreagr.Text & "', '" & passagr.Text & "')"

End If
End Sub