TomDuncan Active Member Licensed User Longtime User Jul 30, 2015 #1 Hi All, I have a program which does this Code: Copy SQL.ExecNonQuery("UPDATE daytimes SET patient = '" & DataToSave & "', modified = 1 " & Where) Where DataToSave is a String. All is fine till today when testing I put in Tom's birthday. What has happened is the ' for Tom has corrupted the data being saved. How can I fix this error. I did think of Encoding Base 64 but then all previous data would not work. Tom oops Saving, sorry about that
Hi All, I have a program which does this Code: Copy SQL.ExecNonQuery("UPDATE daytimes SET patient = '" & DataToSave & "', modified = 1 " & Where) Where DataToSave is a String. All is fine till today when testing I put in Tom's birthday. What has happened is the ' for Tom has corrupted the data being saved. How can I fix this error. I did think of Encoding Base 64 but then all previous data would not work. Tom oops Saving, sorry about that
S sorex Expert Licensed User Longtime User Jul 30, 2015 #2 you need to escape your DataToSave string. Code: Copy SQL.ExecNonQuery("UPDATE daytimes SET patient = '" & DataToSave.replace("'","\'") & "', modified = 1 " & Where) Upvote 0
you need to escape your DataToSave string. Code: Copy SQL.ExecNonQuery("UPDATE daytimes SET patient = '" & DataToSave.replace("'","\'") & "', modified = 1 " & Where)
TomDuncan Active Member Licensed User Longtime User Jul 30, 2015 #3 Thanks for that, will do. Upvote 0
M Mahares Expert Licensed User Longtime User Jul 30, 2015 #4 If you do not want to worry about escaping, you are better off using a parameterised query: Code: Copy SQL.ExecNonQuery2("UPDATE daytimes SET patient = ?, modified = ? " & Where), _ Array As Object(DataToSave, 1)) Upvote 0
If you do not want to worry about escaping, you are better off using a parameterised query: Code: Copy SQL.ExecNonQuery2("UPDATE daytimes SET patient = ?, modified = ? " & Where), _ Array As Object(DataToSave, 1))
Erel B4X founder Staff member Licensed User Longtime User Jul 30, 2015 #5 No. No. No. You need to use parameterized queries: Code: Copy SQL.ExecNonQuery2("UPDATE daytimes SET patient = ?, modified = 1 " & Where, Array (DataToSave)) Edit: Posted together with the post above which is a good solution. Upvote 0
No. No. No. You need to use parameterized queries: Code: Copy SQL.ExecNonQuery2("UPDATE daytimes SET patient = ?, modified = 1 " & Where, Array (DataToSave)) Edit: Posted together with the post above which is a good solution.