K kohle Active Member Licensed User Longtime User Aug 16, 2020 #1 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;")
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;")
Erel B4X founder Staff member Licensed User Longtime User Aug 17, 2020 #2 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. Upvote 0
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.
K kohle Active Member Licensed User Longtime User Aug 17, 2020 #3 Erel said: 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. Click to expand... 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
Erel said: 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. Click to expand... 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.