MrKim Well-Known Member Licensed User Longtime User Jul 25, 2014 #1 What am I missing? The following does not throw any errors but does not update the table either??? Code: Copy If Main.SQL1.IsInitialized = False Then Main.SQL1.Initialize(File.DirInternal, "PartsAndTime.db", False) Main.SQL1.ExecNonQuery("UPDATE TKRecordTemp SET Sent=1, Success=1 WHERE OSID = 101130;") Tried with and without the debugger. The Select Queries on the table all work correctly. Thanks, Kim
What am I missing? The following does not throw any errors but does not update the table either??? Code: Copy If Main.SQL1.IsInitialized = False Then Main.SQL1.Initialize(File.DirInternal, "PartsAndTime.db", False) Main.SQL1.ExecNonQuery("UPDATE TKRecordTemp SET Sent=1, Success=1 WHERE OSID = 101130;") Tried with and without the debugger. The Select Queries on the table all work correctly. Thanks, Kim
M Mrjoey Active Member Licensed User Longtime User Jul 25, 2014 #2 u should use this: Code: Copy Main.SQL1.ExecNonQuery2("UPDATE TKRecordTemp SET Sent=?, Success=? WHERE OSID = ?",array as string(1,1,1231234105)) Upvote 0
u should use this: Code: Copy Main.SQL1.ExecNonQuery2("UPDATE TKRecordTemp SET Sent=?, Success=? WHERE OSID = ?",array as string(1,1,1231234105))
eps Expert Licensed User Longtime User Jul 25, 2014 #3 If you execute this SQL in a SQL editor (I use the Firefox add-on, but others are available) what happens? Does the code work? Are you sure you need the ; at the end? Are you really sure that you aren't making the change, but then somehow overwriting the DB, this can be a common issue in code. Especially as you have to copy the DB from Assets to Internal so that you can make changes to it. What does that part of your code look like? Upvote 0
If you execute this SQL in a SQL editor (I use the Firefox add-on, but others are available) what happens? Does the code work? Are you sure you need the ; at the end? Are you really sure that you aren't making the change, but then somehow overwriting the DB, this can be a common issue in code. Especially as you have to copy the DB from Assets to Internal so that you can make changes to it. What does that part of your code look like?
eps Expert Licensed User Longtime User Jul 25, 2014 #4 Mrjoey said: u should use this: Code: Copy Main.SQL1.ExecNonQuery2("UPDATE TKRecordTemp SET Sent=?, Success=? WHERE OSID = ?",array as string(1,1,1231234105)) Click to expand... You shouldn't need to do that. OP, are Sent and Success numerics? They're not defined as char or string are they? I would execute the SQL as you have it in a SQL Editor on the DB on your machine and see what the result is. That should give you a clue about the problem you are having. HTH Upvote 0
Mrjoey said: u should use this: Code: Copy Main.SQL1.ExecNonQuery2("UPDATE TKRecordTemp SET Sent=?, Success=? WHERE OSID = ?",array as string(1,1,1231234105)) Click to expand... You shouldn't need to do that. OP, are Sent and Success numerics? They're not defined as char or string are they? I would execute the SQL as you have it in a SQL Editor on the DB on your machine and see what the result is. That should give you a clue about the problem you are having. HTH
MrKim Well-Known Member Licensed User Longtime User Jul 25, 2014 #5 eps said: If you execute this SQL in a SQL editor (I use the Firefox add-on, but others are available) what happens? Does the code work? Are you sure you need the ; at the end? Are you really sure that you aren't making the change, but then somehow overwriting the DB, this can be a common issue in code. Especially as you have to copy the DB from Assets to Internal so that you can make changes to it. What does that part of your code look like? Click to expand... I know the change is not being made as a subsequent query to retrieve the records finds no records. A query with the old criteria does. RE. the semicolon. IT is my understanding that a ; on the end is good programming practice. It indicates the end of an SQL statement. As a practical matter for single queries it does seem to make no difference. I have never had it be an issue, and I tried with and without. Upvote 0
eps said: If you execute this SQL in a SQL editor (I use the Firefox add-on, but others are available) what happens? Does the code work? Are you sure you need the ; at the end? Are you really sure that you aren't making the change, but then somehow overwriting the DB, this can be a common issue in code. Especially as you have to copy the DB from Assets to Internal so that you can make changes to it. What does that part of your code look like? Click to expand... I know the change is not being made as a subsequent query to retrieve the records finds no records. A query with the old criteria does. RE. the semicolon. IT is my understanding that a ; on the end is good programming practice. It indicates the end of an SQL statement. As a practical matter for single queries it does seem to make no difference. I have never had it be an issue, and I tried with and without.
S sorex Expert Licensed User Longtime User Jul 25, 2014 #6 is there any delay between the update and the select after it? it might run async since it doesn't need to pull data back to your app. Upvote 0
is there any delay between the update and the select after it? it might run async since it doesn't need to pull data back to your app.
S sorex Expert Licensed User Longtime User Jul 25, 2014 #7 by the way are you sure there is a record with OSID = 101130 ? if not it won't throw any errors either. Upvote 0
by the way are you sure there is a record with OSID = 101130 ? if not it won't throw any errors either.
MrKim Well-Known Member Licensed User Longtime User Jul 25, 2014 #8 Yes, I even tried no criteria. Still didn't work. So I tried a delete query thinking the table was locked for some reason and it deleted them all. Upvote 0
Yes, I even tried no criteria. Still didn't work. So I tried a delete query thinking the table was locked for some reason and it deleted them all.
Erel B4X founder Staff member Licensed User Longtime User Jul 26, 2014 #9 Have you explicitly started transaction? If yes then you should make sure that it is closed properly. Upvote 0
Have you explicitly started transaction? If yes then you should make sure that it is closed properly.
MrKim Well-Known Member Licensed User Longtime User Jul 27, 2014 #10 Sigh, I figured it out. SQL Lite is not explicitly typed but says it stores things as what they, I guess what that really means is that if you don't specify a type it stores a string. Even though the field is ALWAYS a long when I wrapped it in single quotes it worked Code: Copy WHERE OSID = '101130'; . So I went back and specified the type and it worked as it should. I was in a hurry to get things working and it came back and bit me . Upvote 0
Sigh, I figured it out. SQL Lite is not explicitly typed but says it stores things as what they, I guess what that really means is that if you don't specify a type it stores a string. Even though the field is ALWAYS a long when I wrapped it in single quotes it worked Code: Copy WHERE OSID = '101130'; . So I went back and specified the type and it worked as it should. I was in a hurry to get things working and it came back and bit me .