Database is empty

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Helo,

i fill my database with tihs code

B4X:
SQL1.ExecNonQuery2("INSERT INTO nachrichten VALUES(?,?,?,?,?)", Array As Object(ayir(0), ayir(1), ayir(2), ayir(3),ayir(4) ))

and i call the database Contents with this code
B4X:
Dim Cursor1 As Cursor
   Cursor1 = SQL1.ExecQuery("SELECT Name, Nummer, msg, Link, Datum FROM nachrichten")
   For i = 0 To Cursor1.RowCount - 1
      Cursor1.Position = i
      
      Spalte1 = Cursor1.GetString("Name")
      Spalte2 = Cursor1.GetString("Nummer")
      Spalte3 = Cursor1.GetString("msg")
      Spalte4 = Cursor1.GetString("Link")
      Spalte5 = Cursor1.GetString("Datum")
   Next
   Cursor1.Close

This Problem is, after call the Contents, then is my Database empty.

Why?

can someboady help me ?
 

mangojack

Well-Known Member
Licensed User
Longtime User
Seems to work fine ?

B4X:
  sql1.Initialize(File.DirDefaultExternal,"Data.db",True)
    'sql1.ExecNonQuery("DROP TABLE IF EXISTS nachrichten")
    'sql1.ExecNonQuery("CREATE TABLE IF NOT EXISTS nachrichten (Name TEXT, Nummer TEXT , msg TEXT , Link TEXT , Datum TEXT)")
   
   Dim ayir(5) As String
   Dim Spalte(5) As String
   ayir(0) = "a"
   ayir(1) = "b"
   ayir(2) = "c"
   ayir(3) = "d"
   ayir(4) = "e"

   sql1.ExecNonQuery2("INSERT INTO nachrichten VALUES(?,?,?,?,?)", Array As Object(ayir(0), ayir(1), ayir(2), ayir(3),ayir(4) ))
   
   'this line also works ..
   'sql1.ExecNonQuery2("INSERT INTO nachrichten VALUES(?,?,?,?,?)", ayir)
      
   Dim Cursor1 As Cursor
    Cursor1 = sql1.ExecQuery("SELECT Name, Nummer, msg, Link, Datum FROM nachrichten")
    For i = 0 To Cursor1.RowCount - 1      
      
      Cursor1.Position = i       
        Spalte(0) = Cursor1.GetString("Name")
        Spalte(1) = Cursor1.GetString("Nummer")
        Spalte(2) = Cursor1.GetString("msg")
        Spalte(3) = Cursor1.GetString("Link")
        Spalte(4)= Cursor1.GetString("Datum")
      
      For  k = 0 To 4
         ListView1.AddSingleLine(Spalte(k))
      Next
   Next
    
   Cursor1.Close

Cheers mj
 
Last edited:
Upvote 0

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Helo,

in the first call, the data is available but the next call, the data are not available.

why?
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
with this you are not filling database, you are filling one row of table
B4X:
SQL1.ExecNonQuery2("INSERT INTO nachrichten VALUES(?,?,?,?,?)", Array As Object(ayir(0), ayir(1), ayir(2), ayir(3),ayir(4) ))


with this you are filling database
B4X:
for i = 1 to 3
  SQL1.ExecNonQuery2("INSERT INTO nachrichten VALUES(?,?,?,?,?)", Array As Object(ayir(0), ayir(1), ayir(2), ayir(3),ayir(4) ))
next

Cheers mj
 
Upvote 0

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
helo,

this code crashing my app.

why?

B4X:
For i = 0 To lngCount
ayir1 = codlar.split(s,"#")
ayirilan = ayir1(i)
ayir2 = codlar.split(ayirilan,";")
SQL1.ExecNonQuery2("INSERT INTO nachrichten VALUES(?,?,?,?,?)", Array As Object(ayir2(0), ayir2(1), ayir2(2), ayir2(3),ayir2(4)))
Next
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I suggest you to put a breakpoint on line
SQL1.ExecNonQuery2("INSERT INTO nachrichten VALUES(?,...
run the program in Debug mode and when the program stops at the breakpoint check the content of the different variables.

Best regards.
 
Upvote 0
Top