Android Question Jrdc with ucanaccess not committing inserts (Solved)

kgf

Member
Licensed User
I have Jrdc connecting with ms access ( would prefer not to use access but stuck with it for now). Its working fine for select queries but having trouble with inserts.

I am testing on a simple table with an auto 'id' column and 'UserName' text column with unique constraint. I have the config sql as sql.insert_team=INSERT INTO tblListCurrentTeam (UserName) VALUES (?) and using the commands below.

B4X:
Dim cmd As DBCommand = CreateCommand("insert_team",Array("test name"))
        Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
        Wait For(j) JobDone(j As HttpJob)

In both the B4A and B4J logs the first time I run it, it returns success, if I repeat it, it then shows a unique constraint violation, (HsqlException) org.hsqldb.HsqlException: integrity constraint violation: unique constraint or index violation; TBLLISTCURRENTTEAM_USERNAME table: TBLLISTCURRENTTEAM which is to be expected as the UserNames hould be unique. So it seems to have added a row, BUT when I go to the access table it hasnt been inserted.

I do get this in B4J logs for each table in the database when Jrdc starts but dont know if it is part of the problem. WARNING:Unknown expression: GenUniqueID() (default value of column ...

Tried running both B4J and B4a in release mode and no change, anyone had a similar issue.
 

Ryan Pigeon

Member


This worked for the first edit, but when I try edit record again, it bombs with an error!
 
Upvote 0

Ryan Pigeon

Member
I think it's working - entered con.close after the commit
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
I think it's working - entered con.close after the commit
Strange, since con.close is called in the Handle sub, the sub that makes the ExecuteBatch2 call.
 
Upvote 0

Ryan Pigeon

Member
Strange, since con.close is called in the Handle sub, the sub that makes the ExecuteBatch2 call.

I noticed that, but I am almost there, Oliver! I can read records from db, update records, can delete from db, cannot add more records to db. If I add more records it throws exception.
 
Upvote 0

Ryan Pigeon

Member
OK FOUND THE ISSUE WITH NOT BEING ABLE TO ADD:

Dim Paremeters() As String = Array As String(B4XPages.MainPage.KVS.Get("id_user"), Data.Get("month_c"), Data.Get("event_type"), Data.Get("description"), Data.Get("value_c"))

Is not getting the correct values
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…