Shay Well-Known Member Licensed User Longtime User Jul 16, 2012 #1 Hi I am trying to add to the table some word with ' and the myysql does not like it I cannot remove the ' and I must add the word as is how can i overcome this issue this is the code I am using: SQL1.ExecNonQuery("UPDATE Table_User_Words SET Sounds_Like='" & TextBox_Sound_Like.Text & "',Sounds_Like_Replace='" & TextBox_Sound_Like_Replace.Text & "' WHERE Sounds_Like = '" & Delete_Row & "'") Thanks
Hi I am trying to add to the table some word with ' and the myysql does not like it I cannot remove the ' and I must add the word as is how can i overcome this issue this is the code I am using: SQL1.ExecNonQuery("UPDATE Table_User_Words SET Sounds_Like='" & TextBox_Sound_Like.Text & "',Sounds_Like_Replace='" & TextBox_Sound_Like_Replace.Text & "' WHERE Sounds_Like = '" & Delete_Row & "'") Thanks
stefanobusetto Active Member Licensed User Longtime User Jul 16, 2012 #2 Have you tryed to put it twice? Last edited: Jul 16, 2012 Upvote 0
Shay Well-Known Member Licensed User Longtime User Jul 16, 2012 #3 what does it means? can you give example Upvote 0
mc73 Well-Known Member Licensed User Longtime User Jul 16, 2012 #4 Sure this is mySQL? I think it's an sqLite query. If so, try using execNonQuery2. I think it's a very good choice. Upvote 0
Sure this is mySQL? I think it's an sqLite query. If so, try using execNonQuery2. I think it's a very good choice.
stefanobusetto Active Member Licensed User Longtime User Jul 16, 2012 #5 Sorry the auto correction. I mean if ' is the string delimiter You can put it twice inside a string And yuo' ll get it single Upvote 0
Sorry the auto correction. I mean if ' is the string delimiter You can put it twice inside a string And yuo' ll get it single
P Penko Active Member Licensed User Longtime User Jul 16, 2012 #6 Try logging your query. Then "right click", copy the line and try to manually execute it in MySQL(via PHPMyAdmin for example). It will tell you where the error is. For me this query is pretty much valid. Maybe it has to do with your fields having incorrect names. You can't told us what the exact error you get is. Upvote 0
Try logging your query. Then "right click", copy the line and try to manually execute it in MySQL(via PHPMyAdmin for example). It will tell you where the error is. For me this query is pretty much valid. Maybe it has to do with your fields having incorrect names. You can't told us what the exact error you get is.
mc73 Well-Known Member Licensed User Longtime User Jul 16, 2012 #7 Penko said: Try logging your query. Then "right click", copy the line and try to manually execute it in MySQL(via PHPMyAdmin for example). It will tell you where the error is. For me this query is pretty much valid. Maybe it has to do with your fields having incorrect names. You can't told us what the exact error you get is. Click to expand... Our friend is trying to insert a word starting with ', or so we understood. This thing, just as Stefano suggests, should be done by using a double '. At least this is how we usually see it in mySQL. Still, not quite sure that this cannot be done by simply using execNonQuery2. I haven't tested it. Upvote 0
Penko said: Try logging your query. Then "right click", copy the line and try to manually execute it in MySQL(via PHPMyAdmin for example). It will tell you where the error is. For me this query is pretty much valid. Maybe it has to do with your fields having incorrect names. You can't told us what the exact error you get is. Click to expand... Our friend is trying to insert a word starting with ', or so we understood. This thing, just as Stefano suggests, should be done by using a double '. At least this is how we usually see it in mySQL. Still, not quite sure that this cannot be done by simply using execNonQuery2. I haven't tested it.
pluton Active Member Licensed User Longtime User Jul 16, 2012 #8 When i need to insert into database something with ' I do like this: Example: Code: UPDATE `my_databse` SET `Ime` = 'This is ''testme'' program', `Link` = 'http://ccccccc', `Ikona` = 'http://ccccccp.png' WHERE `my_databse`.`ID` =1 LIMIT 1 You see this testme. It has inserted into database so now is : This is 'testme' program in Upvote 0
When i need to insert into database something with ' I do like this: Example: Code: UPDATE `my_databse` SET `Ime` = 'This is ''testme'' program', `Link` = 'http://ccccccc', `Ikona` = 'http://ccccccp.png' WHERE `my_databse`.`ID` =1 LIMIT 1 You see this testme. It has inserted into database so now is : This is 'testme' program in
P Penko Active Member Licensed User Longtime User Jul 16, 2012 #9 Such scenarios are to be escaped or double-quoted. Therefore, he has to use--> '\'here is the text'. Tested this on MySQL 5.0.51 and it inserts the value: 'here is the text Edit: @pluton was faster. We provided enough solution. The easiest way is to test which works for your case because I think you are missing to share some information with us. Last edited: Jul 16, 2012 Upvote 0
Such scenarios are to be escaped or double-quoted. Therefore, he has to use--> '\'here is the text'. Tested this on MySQL 5.0.51 and it inserts the value: 'here is the text Edit: @pluton was faster. We provided enough solution. The easiest way is to test which works for your case because I think you are missing to share some information with us.
Shay Well-Known Member Licensed User Longtime User Jul 17, 2012 #10 the problem is that when someone tries to insert the word: don't if fails android.database.sqlite.SQLiteException: near "don": syntax error: , while compiling: UPDATE Table_User_Words SET Sounds_Like='don't',Sounds_Like_Replace='aa' WHERE Sounds_Like = 'bbb' i just tried to use '' (2 x ')and it didn't help, I will try the other solutions Upvote 0
the problem is that when someone tries to insert the word: don't if fails android.database.sqlite.SQLiteException: near "don": syntax error: , while compiling: UPDATE Table_User_Words SET Sounds_Like='don't',Sounds_Like_Replace='aa' WHERE Sounds_Like = 'bbb' i just tried to use '' (2 x ')and it didn't help, I will try the other solutions
mc73 Well-Known Member Licensed User Longtime User Jul 17, 2012 #11 Check also this thread, there is a suggestion of mine, plus one of Erel very similar to an earlier of mine here. I think the last one is the key to the solution. Upvote 0
Check also this thread, there is a suggestion of mine, plus one of Erel very similar to an earlier of mine here. I think the last one is the key to the solution.
Shay Well-Known Member Licensed User Longtime User Jul 17, 2012 #12 thanks, this fixed the problem: Dim aaa(3) As String aaa(0)=TextBox_Sound_Like.Text aaa(1)=TextBox_Sound_Like_Replace.Text aaa(2)=Delete_Row Dim queryString As String queryString="UPDATE Table_User_Words SET Sounds_Like = ?, Sounds_Like_Replace = ? WHERE Sounds_Like = ? " SQL1.execNonQuery2(queryString,Array As Object(aaa(0),aaa(1),aaa(2))) Upvote 0
thanks, this fixed the problem: Dim aaa(3) As String aaa(0)=TextBox_Sound_Like.Text aaa(1)=TextBox_Sound_Like_Replace.Text aaa(2)=Delete_Row Dim queryString As String queryString="UPDATE Table_User_Words SET Sounds_Like = ?, Sounds_Like_Replace = ? WHERE Sounds_Like = ? " SQL1.execNonQuery2(queryString,Array As Object(aaa(0),aaa(1),aaa(2)))