Ver Mensaje Individual
  #3 (permalink)  
Antiguo 15/10/2012, 11:14
ramos_1089
 
Fecha de Ingreso: octubre-2012
Mensajes: 5
Antigüedad: 11 años, 6 meses
Puntos: 0
Respuesta: login en vb 2008

mira es te es mi codigo pero ya me funciono perfectamente
pero ahora tengo otro problema quisiera saber como valido si es administrador o otro tipo de cuanta por que en mi bd tengo 2 tipos de cuanta me podrias ayudar

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ingresar.Click
'valida si el usuario y contraseña estan registradas y entra al sistema
Dim ccn As String = "DSN=PostgreSQL35W;UID=mgn_rural;PWD=ruralmgn; "
'<<< PARA SELECCIONAR EL USUARIO Y LA CLAVE DE LA TABLA USUARIO >>>
Dim da As New OdbcDataAdapter("select usuario, contrasenia from tbl_usuarios where usuario='" & txt_usuario.Text & "' and contrasenia='" & txt_contrasenia.Text & "'", ccn)
Dim ds As New DataSet
da.Fill(ds, "tbl_usuarios")
Dim fila As DataRow
'<<< PARA QUE LOS TEXT NO ESTEN VACIO >>>
If txt_usuario.Text = "" And txt_contrasenia.Text = "" Then : MsgBox("Por favor digite el Usuario y la Contraseña para entrar al Sistema...", MsgBoxStyle.Information, "AVISO") : txt_usuario.Select() : Exit Sub
ElseIf txt_usuario.Text = "" Then : MsgBox("Digite el Usuario", MsgBoxStyle.Information, "AVISO") : txt_usuario.Select() : Exit Sub
ElseIf txt_contrasenia.Text = "" Then : MsgBox("Digite la Clave", MsgBoxStyle.Information, "AVISO") : txt_contrasenia.Select() : Exit Sub
End If
For Each fila In ds.Tables("tbl_usuarios").Rows
'<<< SI EL USUARIO Y LA CLAVE SON CORRECTAS PASA AL PROXIMO FORMULARIO >>>
If txt_usuario.Text = fila!usuario And txt_contrasenia.Text = fila!contrasenia Then : Hide() : Opciones.Show() : txt_usuario.Text = "" : txt_contrasenia.Text = "" : Exit Sub
End If
Next
'<<< SI NO SON CORRECTAS EMITIRA EL SIGUIENTE MANSAJE >>>
MsgBox("Usuario Incorrecto. Este Usuario no se encuentra registrado en el Sistema...", MsgBoxStyle.Critical, "AVISO")
txt_usuario.Text = ""
txt_contrasenia.Text = ""
txt_usuario.Select()