Android Question Help to use Dbutils.RecordUpdate

Discussion in 'Android Questions' started by hibrid0, Jun 8, 2015.

  1. hibrid0

    hibrid0 Active Member Licensed User

    Hi, I try to update the record "2" of a table callled "test" with the UpdateRecord and UpdatedRecord2,

    I can add new records with

    DBUtils.InsertMaps(SQL1, "test", ListOfMaps) and this Add a new record.

    I try to update record with:
    Code:
    Mapa_Datos.Put("id""2")

        
    For i = 0 To 150 -1
            
    If i <= 150 Then

            Mapa_Datos.Put((Num_campo&Num_campo2), edt_R(i).text)
            fields_list.Put((Num_campo&Num_campo2), edt_R(i).text)
            Num_campo2=Num_campo2+
    1
            
    Log(edt_R(i).Text)
            
    End If
        
    Next
    ListOfMaps.Add(Mapa_Datos)
    listofFields.add(fields_list)

    DBUtils.UpdateRecord2(SQL1, 
    "test", ListOfFields, ListOfMaps)
    I'm using it wrong, but I dont understand what is wrong.
     
    Last edited: Jun 8, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    Why do you check that i <= 150? It will always be true.

    UpdateRecord and UpdateRecord2 update a single record. Do you want do update multiple records?
     
  3. hibrid0

    hibrid0 Active Member Licensed User

    Because I don't know how do that!. I make that "for" to get 151 fields from the 1 record.
    And I see that cost a lot of power performance(152 queries..).

    I have a database with 152 fields, and I need to get the 151 fields in an array.
    Then I read the 152 fields from the record1, next I get the record2...

    My experience with databases is very limited, and maybe I'm using it wrong.

    In the table I save 152 questions and the next record are the answers.
    I accept suggestions if I'm making it wrong.

    And I'm using a similar code to put info in the db.
     
    Last edited: Jun 9, 2015
  4. Erel

    Erel Administrator Staff Member Licensed User

    hibrid0 likes this.
  5. hibrid0

    hibrid0 Active Member Licensed User

    Then I'm going to change to field "Questions" and other Fields "Answers".
     
  6. klaus

    klaus Expert Licensed User

    Sorry, but I don't understand your database structure. I'm not sure that your structure is the best one.
    What columns do you have in the table ?
    Can you explain it more in detail.
     
  7. hibrid0

    hibrid0 Active Member Licensed User

    Hi Klaus at the moment I have 152 Columns, then in the record 1 (id=1) they are questions I need to show to the user.
    And on the record 2, 3, 4, 5, 6, 7, 8.. I save the answers.
    And with the info from record id=2 I generate a PDF.
     
  8. klaus

    klaus Expert Licensed User

    Do I understand well ? You use 151 columns in record 1, but you use only 1 column with the answer in the next records ?
    Why don't you use two columns one with the questions and the second one with the answers.
    Each record has a question with its answer.
    Or am I missing something ?
     
  9. hibrid0

    hibrid0 Active Member Licensed User

    Hi Klaus I use all columns, Every colums have the questions and the next answers.
    I accept suggetions. In one moment I create a db and upload it.
     
Loading...