Android Question 2 or more data in a Variable

dhernandez

Active Member
Licensed User
Longtime User
as I do the following?

I perform a query to a database when ID_CITY field, this field contains 5 records. These 5 records, how do I assign it to a variable?

I use the Loop For ... Next, I do not know how to put the result of the loop with 2 or more records in a variable ...
Somebody help me.
 

dhernandez

Active Member
Licensed User
Longtime User
I did not understand, could you show me an example or give me more details of what he says?

Thank you ..
 
Upvote 0

dhernandez

Active Member
Licensed User
Longtime User
Thanks for responding, but I think even I see complicated ...
Currently I'm doing this to extract the information and assign it to a variable.

B4X:
Sub enviar_click
'''''CONSULTA DESDE SQLITE PARA ASIGNAR LOS RESULTADOS A LAS SIGUIENTES VARIABLES XD
    Dim idcar As String
    Dim tipo As String
    Dim modelo As String
    Dim stock As String
    Dim usuario As String
   
'''''REALIZO LAS CONSULTAS CORRESPONDIENTES. :D
        CARTUCHOS=SQL1.ExecQuery("SELECT * FROM cartuchos")
            For i = 0 To CARTUCHOS.RowCount -1
                CARTUCHOS.Position = i
                       
                idcar=CARTUCHOS.GetString("id_cartucho")
                tipo=CARTUCHOS.GetString("tipo_cartucho")
                modelo=CARTUCHOS.GetString("modelo_cartucho")
                stock=CARTUCHOS.GetInt("stock_cartucho")
                usuario=CARTUCHOS.GetString("usuario_cartucho")
                'Msgbox(CARTUCHOS.GetString("id_cartucho") & " " & CARTUCHOS.GetString("tipo_cartucho") & " " & CARTUCHOS.GetString("modelo_cartucho") & " " & CARTUCHOS.GetInt("stock_cartucho") & " " & CARTUCHOS.GetString("usuario_cartucho"),"Resultados: ")
            Next
                   
''''''''Recojo los datos de las variables y las envío al servidor remoto...
        ExecuteRemoteQuery("INSERT INTO cartuchos(ID_Cartucho, tipo_cartucho, modelo_cartucho, stock_cartucho, usuario_cartucho)VALUES('" & idcar & "','" & tipo & "','" & modelo & "','" & stock & "','" & usuario & "')",MODELO_LISTA)
        TxtID.text=""
        TxtTipo.text=""
        TxtStock.text=""
        TxtModelo.text=""
        TxtUsuario.text=""
        TxtID.RequestFocus
End Sub


The Loop For .. Next, I collected all the information, but the variable to which I am assigned the result accepts me just one ...

I'm stressed about that. guide me


Rgds
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Straight from the new book...
I suggest you get it as a valuable resourse..
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Are you looking for something like this?
B4X:
CARTUCHOS=SQL1.ExecQuery("SELECT * FROM cartuchos")
  Dim MyRecCount as Int = CARTUCHOS.RowCount
  Dim MyVar(MyRecCount) as String       'Array holding each record
 
For i = 0 To CARTUCHOS.RowCount -1
CARTUCHOS.Position = i
idcar=CARTUCHOS.GetString("id_cartucho")
tipo=CARTUCHOS.GetString("tipo_cartucho")
modelo=CARTUCHOS.GetString("modelo_cartucho")
stock=CARTUCHOS.GetInt("stock_cartucho")
usuario=CARTUCHOS.GetString("usuario_cartucho")
MyVar(i)= idcar & " " &  tipo & " " &  modelo & " "  & stock & " " & usuario
Next
 
Upvote 0

dhernandez

Active Member
Licensed User
Longtime User
Thank you all for your prompt replies . Are monsters of programming ...

Mahares, that works well to show all items adapted.
But now I do not know how to send the SQL Remote using this:

B4X:
ExecuteRemoteQuery("INSERT INTO cartuchos(ID_Cartucho, tipo_cartucho, modelo_cartucho, stock_cartucho, usuario_cartucho)VALUES('" & idcar & "','" & tipo & "','" & modelo & "','" & stock & "','" & usuario & "')",MODELO_LISTA)
        TxtID.text=""
        TxtTipo.text=""
        TxtStock.text=""
        TxtModelo.text=""
        TxtUsuario.text=""
        TxtID.RequestFocus

Thank you for your comments, I really appreciate it.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…