Android Question mi porgram suddenly close while trying to validate info

regtest

New Member
when I want to validate user and password I click on the botonborrar_click but the program closes, what could be happening?

#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region

Sub Process_Globals
Dim s As SQL
Dim c As Cursor
Dim identifica As Int
End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
Private nom As EditText
Private tel As EditText
Private desc As EditText
Private dire As EditText

Private lista As ListView
Private limpiar As Button
Private guardar As Button

Private botonborrar As Button
Private Panel1 As Panel

Private usuario As EditText
Private Password As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
ocultar
If File.Exists(File.DirInternal,"datosUsuarios.db")=False Then
File.Copy(File.DirAssets,"datosUsuarios.db",File.DirInternal,"datosUsuarios.db")
End If

s.Initialize(File.DirInternal,"datosUsuarios.db",True)

Log("cantidad de registros"&s.ExecQuerySingleResult("Select count(*) from datos"))
carga_lista
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Private Sub guardar_Click
Dim tele As Int
tele = tel.Text
If nom.Text<>"" And tel.Text<>"" And desc.Text<>"" And dire.Text<>"" Then
s.ExecNonQuery("insert into datos values(null,'"&nom.Text&"','"&tele&"','"&desc.Text&"','"&dire.Text&"')")
Msgbox("Se inserto bien","insercion")
carga_lista
Else
Msgbox("no Se inserto bien","insercion")
End If
limpiar_Click
End Sub

Private Sub limpiar_Click
nom.Text=""
tel.Text=""
desc.Text=""
dire.Text=""
End Sub

Sub carga_lista
lista.Clear
c=s.ExecQuery("select * from datos")

For n = 0 To c.RowCount-1
c.Position=n

lista.AddSingleLine("Nombre: "&c.GetString("nombre"))
lista.AddSingleLine("Id: "&c.GetString("id"))
lista.SingleLineLayout.ItemHeight=60
lista.SingleLineLayout.Label.TextSize=12
lista.SingleLineLayout.Label.Color=Colors.Cyan
lista.SingleLineLayout.Label.TextColor=Colors.Red
lista.SingleLineLayout.Label.Gravity=Gravity.CENTER_HORIZONTAL

Next
End Sub

Private Sub lista_ItemClick (Position As Int, Value As Object)
Dim idPulsado As String
Dim arreglo As List

idPulsado = Value

arreglo = Regex.Split(":",idPulsado)
Log("el id es: "&arreglo.Get(1))
identifica=arreglo.Get(1)
ToastMessageShow("editar usuario con id:"&identifica,True)
StartActivity(editar)
Activity.Finish

End Sub

Sub ocultar
limpiar.Visible = False
guardar.Visible = False
End Sub

Private Sub botonborrar_Click
Dim usuarioIngresado As String = usuario.Text
Dim passwordIngresado As String = Password.Text
Dim query As String = $"SELECT * FROM acceso WHERE usuario = ? AND password = ?"$
Dim resultado As Int = s.ExecQuerySingleResult2(query, Array As String(usuarioIngresado, passwordIngresado))
If resultado > 0 Then
Msgbox("Acceso concedido.", "Éxito")
Panel1.Visible = False
botonborrar.Visible = False
limpiar.Visible = True
guardar.Visible = True
Else
Msgbox("Usuario o contraseña incorrectos.", "Error")
End If
End Sub
 
Top