AndyGB4
Posts: 122
|
Posted: 04/15/2013, 2:40 PM |
|
Hi everyone,
I have some code that inserts a record into a database, and it is fired up using the Before Show custom code. But the record is being inserted twice.
So I'm thinking that the page itself must be being called twice. Any reason why this could be happening? The previous page is a custom form that the action equals the page in questions. All the details are being sent through the Post method, and it works successfully on the next page.
|
|
|
Lucius
Posts: 220
|
Posted: 04/16/2013, 10:57 AM |
|
Before Show should only be called once, unless it's Before Show Row event.
If you get 2 inserts it's most likely error in your code. Add some debugging variables and output to your code and test when your inserts are launched and why.
|
|
|
AndyGB4
Posts: 122
|
Posted: 04/16/2013, 1:04 PM |
|
Yup, the problem was within my code, I was using executeScalar to get the ID of the last inserted record, but I was unaware that it also executed the query, so I was executing it twice since I also had a executeNonQuery a bit above it.
Problem solved :)
Thanks!
|
|
|
|