Ver Mensaje Individual
  #8 (permalink)  
Antiguo 11/11/2008, 19:23
AlexisLAG
 
Fecha de Ingreso: noviembre-2008
Mensajes: 38
Antigüedad: 15 años, 6 meses
Puntos: 0
De acuerdo Respuesta: Ayuda con toma de BD

Cita:
Iniciado por AlexisLAG Ver Mensaje
HOLA TE ENVIO ALGO PARA QUE PRUEBES O LO ADAPTES A TU GUSTO


Public cnn As New ADODB.Connection
Public RS As New ADODB.Recordset
Public rsS As New ADODB.Recordset
Public RS1 As New ADODB.Recordset



Public Sub IniciarConexion()

With cnn
.CursorLocation = adUseClient
.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\1.mdb" & ";Persist Security Info=False"
End With

End Sub


public sub ENVIAR ()
DIM CORRECTO
CORRECTO = FALSE

If RS.State = adStateOpen Then
RS.Close
End If

sql = "SELECT * FROM usuario""
RS.Open sql, cnn, adOpenStatic, adLockOptimistic



If RS.RecordCount > 0 Then
RS.MoveFirst
' recorre el recordset
While Not RS.EOF
'BUSCA SI SE ENCUENTRAN LOS DATOS INGRESADOS

IF txtNOMBRE = RS!NOMBRE AND txtCONTRASEÑA = RS!CONTRASEÑA THEN
CORRECTO = TRUE
END IF
RS.MoveNext

Wend
End If


IF CORRECTO THEN
LLAMAR AL 2do FORMULARIO
ELSE
MSGBOX " EL USUARIO O CONTRASEÑA SON INCORRECTOS "
LIMPIAR LAS txtNOMBRE Y txt CONTRASEÑA
LLAMAR AL 1º FORMULARIO FORMULARIO
END IF

END SUB

SUERTE

COMO NO CONOZCO TU CODIGO VOY A SUPONER PARTE DE LO QUE HACE



1. AL MOMENTO DE COMENZAR A CORRER EL PROYECTO EN LA SENTECIA LOAD DEL FORMULARIO DE CARGA DE USUARIO Y CONTRASEÑA DEBE LLAMAR A:

Private Sub Form_Load()
.
.
iniciarconexion
.
.
End sub

la tabla debe estar por el momento en el directorio donde estas realizando el proyecto o caso contrario deberias cambiar la linea :

.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\1.mdb" & ";Persist Security Info=False"

por

.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= c:\" & _
"\1.mdb" & ";Persist Security Info=False"



proba los cambio y avisame