SQL select and insert

grafsoft

Well-Known Member
Licensed User
Longtime User
Hi,

I have code that reads

Dim SQL1 As SQL
Dim s,na,nu As String
Dim c As Cursor

SQL1.BeginTransaction
For iz=0 To ContactList.size-1
...
s="insert into anames values ('" & na & "','" & nu & "')"
SQL1.ExecNonQuery(s)
...
next
SQL1.EndTransaction

It runs without an error and should insert some 50 datasets.

Then I execute

c=SQL1.ExecQuery ("select rowid,aname,aphone from anames")
If c.rowcount=0 Then
' it should never get here, but it does
else
' it should go here
end if

The code seems to enter data, but not to find them (?)

:BangHead:

Thank you

Peter
 

Attachments

  • pyp1.zip
    7.3 KB · Views: 195

Mahares

Expert
Licensed User
Longtime User
You did not include a sample fake contact list. So I put a 3 fake contact records in the list.
ContactList.add("mahares" &CRLF & "23538947")
ContactList.add("grafsoft" &CRLF & "2390445347")
ContactList.add("klaus" &CRLF & "4789001")

You need to include the SQL1.TransactionSuccessful statement in the:
Createtable sub:
B4X:
SQL1.ExecNonQuery(s)
   SQL1.TransactionSuccessful  '2/3/2013 Mahares
   SQL1.endTransaction

And also in the insertdata sub
B4X:
Next
      SQL1.TransactionSuccessful '2/3/13 Mahares
      SQL1.EndTransaction

See where I put them for you. I was able to insert and see the data.
 
Upvote 0
Top