Hi , Iam trying to make simple dictionary for my germany lectures, but the problem is that, inspite of inserting data to the table in the DB , its not added and the cursor1.rowcount is always 0!!!
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim SQL1 As SQL
Dim cursor1 As Cursor
Dim Pid As Int
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim EditText1 As EditText
Dim Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
SQL1.Initialize(File.DirDefaultExternal, "Germany.db", True)
CreateTable
InsertManyRows
' Activity.LoadLayout ("CreatDbLayout")
' If File.Exists(File.DirInternal, "Germany.db")=False Then
' SQL1.Initialize(File.DirInternal, "Germany.db", True)
'' CreateTable
' InsertManyRows
' Else
' SQL1.Initialize(File.DirInternal, "Germany.db", True)
' End If
cursor1=SQL1.ExecQuery("SELECT WordId ,GermanyWord ,ArabicWord TEXT,LecNo FROM table1")
Msgbox(cursor1.RowCount,"")
Activity.LoadLayout ("CreatDbLayout")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub CreateTable
SQL1.ExecNonQuery ("DROP TABLE IF EXISTS table1")
SQL1.ExecNonQuery("CREATE TABLE table1(WordId INTEGER,GermanyWord TEXT,ArabicWord TEXT,LecNo INTEGER)")
End Sub
Sub Button1_Click
Pid=EditText1.Text
cursor1.Position =Pid
Msgbox(cursor1.GetString("GermanyWord"),cursor1.GetInt("WordId"))
End Sub
Sub InsertManyRows
SQL1.BeginTransaction
Try
'21-6-2015
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
SQL1.ExecNonQuery("INSERT INTO table1 VALUES('0','der Advent','مجيء','7')")
SQL1.ExecNonQuery("INSERT INTO table1 VALUES('1','der Adventskranz','إكليل قدوم','7')")
SQL1.ExecNonQuery("INSERT INTO table1 VALUES('2','der Anlass','بمناسبة','7')")
SQL1.ExecNonQuery("INSERT INTO table1 VALUES('3','der April','أبريل','7')")
SQL1.ExecNonQuery("INSERT INTO table1 VALUES('4','die Atmosphäre','الجو','7')")
SQL1.ExecNonQuery("INSERT INTO table1 VALUES('5','die Aufregung','الإثارة','7')")
SQL1.ExecNonQuery("INSERT INTO table1 VALUES('6','der Backofen','الفرن','7')")
SQL1.ExecNonQuery("INSERT INTO table1 VALUES('7','die Bäuerin','زوجة المزارع','7')")
SQL1.ExecNonQuery("INSERT INTO table1 VALUES('8','der Bikini','بيكيني','7')")
SQL1.ExecNonQuery("INSERT INTO table1 VALUES('9','der Blumenstrauß','باقة','7')")
SQL1.ExecNonQuery("INSERT INTO table1 VALUES('10','die Bluse','بلوزة','7')")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
SQL1.TransactionSuccessful
Catch
End Try
SQL1.EndTransaction
Msgbox("O.K","")
End Sub