weird scenario after executing prepared statement mysql
-
I got these very weird scenario i encounter. it happens when i try execute the sample provided in mysql doc about prepared statement, i created the table with columns correspond with the sample. mysql prepared statement then when i execute it(BTW i used the c# sample), it populate the rows with 1000 entries. after that i try to insert one entry with out the prepared statement (at this moment the ignore prepare property is set to true), then the executeNonQuery return 1, so it means it inserted the so i checked the database but the value i inserted is not in there, so i try it many time but still no luck. so i decide to write the insert query directly to workbench, but i got thesame result the data was not there. so i tried to delete the last row, then the weird things happen. it delete the the last row that has an the id of 1000(btw the id was autoincrement) it also insert 1 new data with the id of 1001, so try to delete to rows but after the two rows was deleted it also insert two more rows with the id of 1002 and 1003. then after that i tried to insert new data but is still keep telling me that 1 row is inserted but i cant see that on the table so, i tried to delete rows still bu t it still doing the same. BTW as u can see on the documentation the second column is a number, then when i delete the data it also insert now row with the incremented value of it. so i decide to truncate the table and insert few row and then delete some of it, at this point it was working as expected, then i decide to execute the prepared statement(ignore prepare set to false) then after that it do the same weird things. i dont know what on this, could somebody explain to me. i will appreciate for any enlightenment will come. thank you very much
-
I got these very weird scenario i encounter. it happens when i try execute the sample provided in mysql doc about prepared statement, i created the table with columns correspond with the sample. mysql prepared statement then when i execute it(BTW i used the c# sample), it populate the rows with 1000 entries. after that i try to insert one entry with out the prepared statement (at this moment the ignore prepare property is set to true), then the executeNonQuery return 1, so it means it inserted the so i checked the database but the value i inserted is not in there, so i try it many time but still no luck. so i decide to write the insert query directly to workbench, but i got thesame result the data was not there. so i tried to delete the last row, then the weird things happen. it delete the the last row that has an the id of 1000(btw the id was autoincrement) it also insert 1 new data with the id of 1001, so try to delete to rows but after the two rows was deleted it also insert two more rows with the id of 1002 and 1003. then after that i tried to insert new data but is still keep telling me that 1 row is inserted but i cant see that on the table so, i tried to delete rows still bu t it still doing the same. BTW as u can see on the documentation the second column is a number, then when i delete the data it also insert now row with the incremented value of it. so i decide to truncate the table and insert few row and then delete some of it, at this point it was working as expected, then i decide to execute the prepared statement(ignore prepare set to false) then after that it do the same weird things. i dont know what on this, could somebody explain to me. i will appreciate for any enlightenment will come. thank you very much
Can you show us the query you are using to check the new rows, you allegedly inserted? You may also add your insert command... Also read here to understand what ExecuteNonQuery exactly returns - http://waldev.blogspot.co.il/2008/01/return-value-of-executenonquery-in.html[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
-
Can you show us the query you are using to check the new rows, you allegedly inserted? You may also add your insert command... Also read here to understand what ExecuteNonQuery exactly returns - http://waldev.blogspot.co.il/2008/01/return-value-of-executenonquery-in.html[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
actually I am using workbench and sqlyog for browsing the database. executing insert or delete, ExecuteNonQuery return the expected number of rows to be affected on the console, but when i look on the database the affected rows is not there. even i will execute directly it to workbench or sqlyog i got the same behavior.