Ver Mensaje Individual
  #3 (permalink)  
Antiguo 20/10/2008, 05:59
beamm
 
Fecha de Ingreso: octubre-2008
Mensajes: 42
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: ayuda con el manejo de erroressssss en asp.net

Hola Titancete, me parece que tu y yo estamos haciendo algo muy parecido, jejej, a mi me ayudaron mucho en este foro, mi tema está por ahi pero te pongo el código para identificar un usuario que al final me funcionó a mi. Es este, espero que te ayude en algo:


Protected Sub Aceptar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Aceptar.Click
Dim a, b As String
Dim resul As OleDbDataReader


Dim cnn As OleDbConnection

If DropDownList1.Text = "Profesor" Then

a = TextBox1.Text
b = TextBox2.Text


cnn = New OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Documents and Settings\Bea.BEA-095B12391FA\Mis documentos\Visual Studio 2005\WebSites\GestionAulas\App_Data\gestionaulas.m db")
cnn.Open()
Dim query As String = "SELECT Apellido " & _
"FROM Profesor " & _
"WHERE DNI = '" & a & "'" _
& "AND Contraseña = '" & b & "'"

Dim objCmd As New OleDbCommand(query, cnn)
resul = objCmd.ExecuteReader()


Dim apellido As String = String.Empty

While resul.Read()
apellido = resul.GetString(0)
End While


cnn.Close()


If apellido <> String.Empty Then
Response.Redirect("~/Profesor.aspx")
Else : Response.Write("El usuario no existe")

End If


ElseIf DropDownList1.Text = "Conserje" Then

a = TextBox1.Text
b = TextBox2.Text


cnn = New OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Documents and Settings\Bea.BEA-095B12391FA\Mis documentos\Visual Studio 2005\WebSites\GestionAulas\App_Data\gestionaulas.m db")
cnn.Open()
Dim query As String = "SELECT Apellido " & _
"FROM Conserje " & _
"WHERE DNI = '" & a & "'" _
& "AND Contraseña = '" & b & "'"

Dim objCmd As New OleDbCommand(query, cnn)
resul = objCmd.ExecuteReader()


Dim apellido As String = String.Empty

While resul.Read()
apellido = resul.GetString(0) 'esto retornara el nombre
End While


cnn.Close()


If apellido <> String.Empty Then
Response.Redirect("~/Conserje.aspx")
Else : Response.Write("El usuario no existe")

End If

ElseIf DropDownList1.Text = "Administrador" Then

a = TextBox1.Text
b = TextBox2.Text


cnn = New OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Documents and Settings\Bea.BEA-095B12391FA\Mis documentos\Visual Studio 2005\WebSites\GestionAulas\App_Data\gestionaulas.m db")
cnn.Open()
Dim query As String = "SELECT Apellido " & _
"FROM Administrador " & _
"WHERE DNI = '" & a & "'" _
& "AND Contraseña = '" & b & "'"

Dim objCmd As New OleDbCommand(query, cnn)
resul = objCmd.ExecuteReader()


Dim apellido As String = String.Empty

While resul.Read()
apellido = resul.GetString(0) 'esto retornara el nombre
End While


cnn.Close()


If apellido <> String.Empty Then
Response.Redirect("~/Administrador.aspx")
Else : Response.Write("El usuario no existe")

End If

End If
End Sub