Hello Everyone,
I have a problem with Insert statement.
Though My SQL Statement executed once only, there are 2 records entered in DB.
I am using ASP and SQL Server.
Does anybody know the solution?
| SitePoint Sponsor |
Hello Everyone,
I have a problem with Insert statement.
Though My SQL Statement executed once only, there are 2 records entered in DB.
I am using ASP and SQL Server.
Does anybody know the solution?
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company





Without seeing the code and understanding the DB structure? No.
Sql Query Is As Follow:
logSQLQuery = "INSERT INTO ActivityLog (ActivityLogGUID, ActivityGUID, UserGUID, AnswerFlag) VALUES('" & ActivityLogGUID & "', '" & ActivityGUID & "', '" & Session("UserGUID") & "', " & Answer & ")"
Conn.Execute(logSQlQuery)
DB:
Table Name:ActivityLog
Columns:
ActivityLogGUID guid unique
ActivityGUID guid unique
UserGUID guid unique
AnswerFlag flag
Hope this will make sense to you...
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company





Are any of those fields set as AutoNumber/AutoIncrement?
What happens if you try an equivalent hard-coded query in the MS SQL query manager?
Thanks for you kind response.
No fields are set to AutoNumber/AutoIncrement.
Following is the structure of my table.
Field Type
-----------------------------------------------
ActivityLogGUID uniqueIdentifier
ActivityDateTime getNow() - default value
ActivityGUID uniqueIdentifier
UserGUID uniqueIdentifier
AnswerFlag Bit
If I am entering query through Query Manager, only 1 record is entered.
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company





If this action is being initiated by a <form>, make sure you are not submitting it twice (check any validation javascript)
No I have checked again that.
Form is submitting once only.
I have apply following trick also to check whether query is executed more than once.
Query is printed only once but in database there are 2 records are inserted.Code:logSQLQuery = "INSERT INTO ActivityLog (ActivityLogGUID, ActivityGUID, UserGUID, AnswerFlag) VALUES('" & ActivityLogGUID & "', '" & ActivityGUID & "', '" & Session("UserGUID") & "', " & Answer & ")" Conn.Execute logSQLQuery Response.write logSQLQuery Response.End
So I am sure there is a problem with execution of Insert Query.
Is this a SQL Bug?
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company





NoIs this a SQL Bug?
Post the entire ASP page and the page that contains the form you are submitting.
Hi Jim,
May I mail you the pages?
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company





PM me them please
Jim,
I am not able to attach the code im PM as code are so long and PM allow only 8192 characters.
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company
Anybody have a chance to look at this??
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company





How about save the .asp page as .txt, upload it to your site, then PM us with the link or post the link here?
Siteguru,
May I mail you?
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company





No. Just post a link or PM it.
I don't have a live site working currently and PM allow only 8192 characters.
That's why I am asking you to mail?
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company

Just save it as a text file and post it in this thread as an attachment. That way everyone can get in on the conversation.
Thanks Dave.
I never seen this option as I am using Quick Reply always.
I will post the code soon...
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company
Both the pages are attached here...
Please help..
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company

Hmmm. Nothing's jumping out that's glaringly wrong. the only thing I would think to try would be to get rid of the extraneous recordsets on the inserts
So
Set AnswerRS = Conn.Execute(SQLQuery)
Becomes
Conn.Execute SQLQuery
But that is only a performance saving - that shouldn't cause two hits to that insert statement.
Are you getting dups on every insert, or just that one table?
I have tried this one previously but no luck...Set AnswerRS = Conn.Execute(SQLQuery)
Becomes
Conn.Execute SQLQuery
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company
No. I have another 30-40 pages and many insert queries but they are running superbly.Are you getting dups on every insert, or just that one table?
I am getting this duplicate when queries submitted to this page only...
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company

OK, but are the dups only to the ActivityLog table, or are you getting dups on the ActivityAnswers and ActivityMessages tables as well?





There's a lot of javascript on that page, an ajax form submit function and a real form submit function, are you sure they're not both being called?
Best Joomla Web Design and Development Agency :--:
PSD to Joomla :--: Award Winning Web Design Company
Bookmarks