B4J Question DBUtils: Broken?

Discussion in 'B4J Questions' started by ShaneG30, Aug 1, 2015.

  1. ShaneG30

    ShaneG30 Well-Known Member Licensed User

    Code:
    TheSQL.InitializeSQLite(File.DirApp, "db.db"True)

      
    Dim Fields As Map
    Fields.Initialize
    Fields.Put(
    "Name""TEXT")

    Dim ListOfMaps As List
    ListOfMaps.Initialize
    Dim M As Map
    M.Initialize
    M.Put(
    "Name""Olimar")
    M.Put(
    "Name""Louie")
    M.Put(
    "Name""Alph")
    ListOfMaps.Add(M)
            
    DBUtils.CreateTable(TheSQL, 
    "Name", Fields , "Key")
    DBUtils.InsertMaps(TheSQL, 
    "Name", ListOfMaps)
    DBUtils.ExecuteTableView(TheSQL, 
    "SELECT Name FROM Name"Null1, TableView1)
    Code doesn't insert all three keys. Already tried a "For" statement. Doesn't work. TableView1 only displays Alph.
     
  2. Eumel

    Eumel Active Member Licensed User

    You overwrite the key "Name" always, so only the last record will insert.

    Code:
    Dim M As Map
    M.Initialize
    M.Put(
    "Name""Olimar")
    ListOfMaps.Add(M)
    Dim M As Map
    M.Initialize
    M.Put(
    "Name""Louie")
    ListOfMaps.Add(M)
    Dim M As Map
    M.Initialize
    M.Put(
    "Name""Alph")
    ListOfMaps.Add(M)
     
    ShaneG30 likes this.
  3. ShaneG30

    ShaneG30 Well-Known Member Licensed User

    Tried it, and it still displays the last record.

    Code:

    Code:
    Dim Fields As Map
    Fields.Initialize
    Fields.Put(
    "Name""TEXT")

    Dim ListOfMaps As List
    ListOfMaps.Initialize
    Dim M As Map
    M.Initialize
    M.Put(
    "Name""Olimar")
    ListOfMaps.Add(M)
    Dim M As Map
    M.Initialize
    M.Put(
    "Name""Louie")
    ListOfMaps.Add(M)
    Dim M As Map
    M.Initialize
    M.Put(
    "Name""Alph")
    ListOfMaps.Add(M)


    DBUtils.CreateTable(TheSQL, 
    "Name", Fields , "Key")
    DBUtils.InsertMaps(TheSQL, 
    "Name", ListOfMaps)
    DBUtils.ExecuteTableView(TheSQL, 
    "SELECT Name FROM Name"Null1, TableView1)
    I honestly have no idea why it still displays the last record.
     
  4. rwblinn

    rwblinn Well-Known Member Licensed User

    Hi,

    change the Limit from 1 to 0 in ExecuteTableView and the records are shown. Just tested in a sample app.

    Code:
    DBUtils.ExecuteTableView(TheSQL, "SELECT Name FROM Name"Null0, TableView1)
     
    Erel and ShaneG30 like this.
  5. ShaneG30

    ShaneG30 Well-Known Member Licensed User

    @rwblinn
    @Eumel

    It works! Thanks! (I'm switching to DBUtils for all my SQL needs; and after this test, DBUtils is freaking awesome and super easy.)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice