Ver Mensaje Individual
  #5 (permalink)  
Antiguo 20/08/2009, 00:31
Avatar de pampa_
pampa_
 
Fecha de Ingreso: mayo-2006
Mensajes: 334
Antigüedad: 19 años
Puntos: 1
Respuesta: ayuda para tener distintos login segun usuario

yo ando en algo parecido... te escribo lo que hice y espero q te sirva de ayuda

Using conexion As New Data.SqlClient.SqlConnection(conex)

Dim columnas As String = "([login],[password])"
Dim usuario As String = TextBox1.Text
Dim password As String = TextBox2.Text
Session("usuario") = TextBox1.Text

If TextBox1.Text = "" Or TextBox2.Text = "" Then
TextBox1.BorderColor = Color.Red
TextBox2.BorderColor = Color.Red
GoTo FIN
End If

If TextBox1.BorderColor = Color.Red Or TextBox2.BorderColor = Color.Red Then
TextBox1.BorderColor = Color.White
TextBox2.BorderColor = Color.White
End If

'*********************
Dim dr As SqlClient.SqlDataReader
Dim filtro As String
'Dim dAdapter As New SqlDataAdapter(filtro, conexion)
'Dim datos As New DataTable

'dAdapter.Fill(datos)

'If datos.Rows.Count > 0 Then
'MsgBox("Login correcto")
'End If

filtro = "select nivel from login WHERE usuario='" & Trim(Replace(Me.TextBox1.Text, "'", "k")) & "' AND contraseña='" & Trim(Replace(Me.TextBox2.Text, "'", "k")) & "' "
Dim cmd As New SqlCommand(filtro, conexion)
' Dim consulta As SqlDataAdapter = New SqlDataAdapter(filtro, conex)
conexion.Open()

cmd = New SqlClient.SqlCommand(filtro, conexion)

dr = cmd.ExecuteReader()

If dr.Read() Then
If dr.Item("nivel") = "1" Then
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
Button6.Enabled = True
button2.Enabled = True
button5.Enabled = True
button7.Enabled = True
'MsgBox("Has entrado")
Else
button2.Enabled = True
button7.Enabled = True
'MsgBox("pringao")
End If

End If
conexion.Close()
FIN:
End Using

teniendo en la base de datos un campo que sea nivel, filtras el tipo de usuario, este codigo lo tengo puesto en un boton que se llama "iniciar sesion" con los datos determinas el nivel de privilegio del usuario y de esta manera haces q ciertos campos de la web este enabled o disabled.

Espero que te sirva de ayuda