Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim BDSQL As JdbcSQL
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
Private Button1 As Button
Private SelCliente As AutoCompleteEditText
Private ResulClien As B4XTable
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
ResulClien.AddColumn("Nombre empresa", ResulClien.COLUMN_TYPE_TEXT)
BDSQL.InitializeAsync("BDSQL", "net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://192.168.1.44;databaseName=Custom;user=sa;password=(EDITADO);appname=Custom;wsid=TEST;loginTimeout=10;socketTimeout=10", "", "")
End Sub
Sub Button1_Click
Dim Datos As List
Datos.Initialize
BDSQL.ExecQueryAsync("Consulta", "SELECT NombreComercial FROM Empresas WHERE NombreComercial LIKE N'%" & SelCliente.Text & "%'" , Null)
Wait For Consulta_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
If Success = True Then
Do While Crsr.NextRow
Dim Fila(1) As Object
Fila(0) = Crsr.GetString("NombreComercial")
Datos.Add(Fila)
Loop
Crsr.Close
ResulClien.SetData(Fila)
Else
MsgboxAsync("mal","Falló")
End If
End Sub