ayuda con Visial Basic 6.0
Publicado por Martha (1 intervención) el 22/08/2009 03:49:17
Hola me gustaria queme ayudaran con este error , resulta que quiero ingresar el id y password de usuario para iniciar el sistema pero me manda a decir : " no coinciden los tipos de datos en la expresion de criterios" no se que estou haciendo mal si alguien me ayuda a corregir. desde ya gracias
el codigo es el siguiente:
Option Explicit
Private Sub cmdingresar_Click()
Set rst = Nothing
Set rst = New ADODB.Recordset
CadenaSQL = "select * from usuario" & " where nombre ='" & Val(Me.txtident.Text) & "'" _
& " and Password= " & Val(Me.txtpas.Text) & ""
With rst
.Source = CadenaSQL
.ActiveConnection = cnn
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Open
End With
If Not rst.EOF Then
If Trim(Me.txtident.Text = rst.Fields!nombre) And Trim(Me.txtpas = rst.Fields!Password) Then
MsgBox " Bienvenido Sr.(a)", vbExclamation, " Iniciando de Secion"
Unload frmSplash
MDIsistema.Show
Else
If Trim(Me.txtident = "" Or Me.txtpas = "") Then
MsgBox " Sr. Usuario Ingrese sus datos", vbInformation + vbCritical, "Inicio de Secion"
Me.txtident.SetFocus
Else
If Trim(Me.txtpas = "") And Trim(Me.txtident = rst.Fields!nombre) Then
MsgBox "Sr.Usuario no Ingreso la Contraseña, Escriba la contraseña", vbInformation, "Escriba la contraseña de usuario"
Me.txtpas.SetFocus
Else
If Trim(Me.txtident = "") And Trim(Me.txtpas = rst.Fields!Password) Then
MsgBox "Sr.Usuario ingrese su nombre de usuario, Escriba la contraseña", vbInformation, "Escriba la contraseña de usuario"
Me.txtpas.SetFocus
Else
If Trim(Me.txtpas) <> Trim(rst.Fields!Password) And Trim(Me.txtident) = Trim(rst.Fields!nombre) Then
MsgBox "Contraseña no válida. Intente de Nuevo ", vbInformation, " Escriba la contraseña correcta"
Me.txtpas.SetFocus
Else
If Trim(Me.txtident) <> Trim(rst.Fields!nombre) And Trim(Me.txtpas) = Trim(rst.Fields!Password) Then
MsgBox "Nombre de usuario no válido. Intente de Nuevo ", vbInformation, "Escriba el nombre de Usuario Correcto"
Me.txtident.SetFocus
End If
End If
End If
End If
End If
End If
End If
End Sub
Private Sub cmdsalir_Click()
End
End Sub
Private Sub Form_Load()
AbrirMainDB
End Sub
Private Sub txtident_Change()
If Len(txtident.Text) <= 15 Then
Val (Me.txtident.Text)
Else
MsgBox " La Longitud Maxima de ID es de 15 caracteres", vbInformation, "Ingrese Nuevamente su ID"
Me.txtident.Text = ""
Me.txtident.SetFocus
End If
End Sub
Private Sub txtident_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me.txtpas.SetFocus
KeyAscii = 0
Else
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End If
End Sub
Private Sub txtpas_Change()
If Len(Me.txtpas.Text) <= 8 Then
Val (Me.txtpas.Text)
Else
MsgBox " La Longitud maxima para la clave es de 8 caracteres", vbInformation, "Ingrese Nuevamente la clave"
Me.txtpas.Text = ""
Me.txtpas.SetFocus
End If
End Sub
Private Sub txtpas_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me.cmdingresar.SetFocus
Else
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End If
End Sub
el codigo es el siguiente:
Option Explicit
Private Sub cmdingresar_Click()
Set rst = Nothing
Set rst = New ADODB.Recordset
CadenaSQL = "select * from usuario" & " where nombre ='" & Val(Me.txtident.Text) & "'" _
& " and Password= " & Val(Me.txtpas.Text) & ""
With rst
.Source = CadenaSQL
.ActiveConnection = cnn
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Open
End With
If Not rst.EOF Then
If Trim(Me.txtident.Text = rst.Fields!nombre) And Trim(Me.txtpas = rst.Fields!Password) Then
MsgBox " Bienvenido Sr.(a)", vbExclamation, " Iniciando de Secion"
Unload frmSplash
MDIsistema.Show
Else
If Trim(Me.txtident = "" Or Me.txtpas = "") Then
MsgBox " Sr. Usuario Ingrese sus datos", vbInformation + vbCritical, "Inicio de Secion"
Me.txtident.SetFocus
Else
If Trim(Me.txtpas = "") And Trim(Me.txtident = rst.Fields!nombre) Then
MsgBox "Sr.Usuario no Ingreso la Contraseña, Escriba la contraseña", vbInformation, "Escriba la contraseña de usuario"
Me.txtpas.SetFocus
Else
If Trim(Me.txtident = "") And Trim(Me.txtpas = rst.Fields!Password) Then
MsgBox "Sr.Usuario ingrese su nombre de usuario, Escriba la contraseña", vbInformation, "Escriba la contraseña de usuario"
Me.txtpas.SetFocus
Else
If Trim(Me.txtpas) <> Trim(rst.Fields!Password) And Trim(Me.txtident) = Trim(rst.Fields!nombre) Then
MsgBox "Contraseña no válida. Intente de Nuevo ", vbInformation, " Escriba la contraseña correcta"
Me.txtpas.SetFocus
Else
If Trim(Me.txtident) <> Trim(rst.Fields!nombre) And Trim(Me.txtpas) = Trim(rst.Fields!Password) Then
MsgBox "Nombre de usuario no válido. Intente de Nuevo ", vbInformation, "Escriba el nombre de Usuario Correcto"
Me.txtident.SetFocus
End If
End If
End If
End If
End If
End If
End If
End Sub
Private Sub cmdsalir_Click()
End
End Sub
Private Sub Form_Load()
AbrirMainDB
End Sub
Private Sub txtident_Change()
If Len(txtident.Text) <= 15 Then
Val (Me.txtident.Text)
Else
MsgBox " La Longitud Maxima de ID es de 15 caracteres", vbInformation, "Ingrese Nuevamente su ID"
Me.txtident.Text = ""
Me.txtident.SetFocus
End If
End Sub
Private Sub txtident_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me.txtpas.SetFocus
KeyAscii = 0
Else
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End If
End Sub
Private Sub txtpas_Change()
If Len(Me.txtpas.Text) <= 8 Then
Val (Me.txtpas.Text)
Else
MsgBox " La Longitud maxima para la clave es de 8 caracteres", vbInformation, "Ingrese Nuevamente la clave"
Me.txtpas.Text = ""
Me.txtpas.SetFocus
End If
End Sub
Private Sub txtpas_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me.cmdingresar.SetFocus
Else
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End If
End Sub
Valora esta pregunta


0