Android Question Insert Array value to device data base

manuaaa

Member
Licensed User
Longtime User
Dear Erel,

Please help me to add value from my web server to devise database I am using code like.


a.setDatabase("118.XX.XX.175","mXXXXn","XXXXXX","xxxxxxx")
L= a.Query("select * from TabDate")
For i = 1 To L.Size -1
SQL1.ExecNonQuery2("INSERT INTO datemstr VALUES (?, ?, ?, ?, ?)", Array As Object(i)
Next

Please help me
manoj
 

Mahares

Expert
Licensed User
Longtime User
I think you need something like this. I did not have a chance to test it:
B4X:
a.setDatabase("118.XX.XX.175","mXXXXn","XXXXXX","xxxxxxx")
L= a.Query("select * from TabDate")
For i = 1 To L.Size -1
   Dim MyRecord As String=L.Get(i)
   MyRecord=MyRecord.Replace("[","").Replace("]","")     'get rid of brackets in each record
   Dim strRecArray() As String
   strRecArray=Regex.Split(",",MyRecord)
   SQL1.ExecNonQuery2("INSERT INTO datemstr VALUES (?, ?, ?, ?, ?)", Array As Object(strRecArray))
Next
 
Upvote 0

manuaaa

Member
Licensed User
Longtime User
Dear Mahares,

Thanks for your replay, it is not add the value only number of columns is adding in devise database table with null values. when i tried to call strRecArray in message box I got a message like [Ljava.lang.string4a2f9128
please help..

thanks
 
Upvote 0

manuaaa

Member
Licensed User
Longtime User
thanks erel, now i got a error
android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x23d7c8
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I am guessing that the number of columns in your MySQL remote table does not match the number of columns in your SQLite table which you show it to be 5 in the SQLite table. If you are sure they are the same, then the problem is somewhere else.
 
Upvote 0

manuaaa

Member
Licensed User
Longtime User
i am giving my screen shoots of error and data base. Were u can see the values getting from server and below the table designe of devise database. pl. help me. thanks - manoj
 

Attachments

  • sqlite.JPG
    106.1 KB · Views: 534
  • b4a.JPG
    203.5 KB · Views: 608
Upvote 0

manuaaa

Member
Licensed User
Longtime User
hi all,

finally I used the following:

SQL1.ExecNonQuery("INSERT INTO datemstr VALUES(" & strRecArray(0) & ",'" & strRecArray(1) & "','" & strRecArray(2) & "','" & strRecArray(3) & "','" & strRecArray(4) & "')")

ONLY THE DATE VALUE NOT INSERTED PROPERLY REST EVERYTHING IS o.k. IN THE DATE COLUMN DECLARED TYPE IS NOT MATCHING I HOPE. i WILL COME BACK AFTER CORRECTING THE SAME.

tHANKS, THANKS, THANKS
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…