B4J Question Null Parameter in SQL (ucanaccess)

kohle

Active Member
Licensed User
Longtime User
I have a table in access with a foreign key.

I try to make an insert, but get an foreign key violation in b4J. With an other tool I can execute the sql without a problem.
The problem is, I must pass the value Null. But some how it dont work in b4j.

B4X:
dim strSQL as string

strSQL=" INSERT into t_test(id, persnr, name) values (5021,Null, 'Herbert' )  "

sql.BeginTransaction
sql.ExecNonQuery(strSQL)
sql.TransactionSuccessful
 sql.ExecNonQuery("COMMIT;")
 

kohle

Active Member
Licensed User
Longtime User
B4J doesn't do anything with the SQL command except of passing it to the SQL driver.

Try sql.ExecNonQuery2 and pass Null in the array.

I found the problem and solved it like this :

The field has a foreign key to another table. In other tools there is no problem if you pass Null as foreign key. (mdb viewer plus)

Now I do it like this : I insert with a known value like 1 and update after with Null.

rg
J.
 
Upvote 0
Top