SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 37

Hybrid View

  1. #1
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Duplicate Entries

    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?

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Without seeing the code and understanding the DB structure? No.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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...

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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?
    Ian Anderson
    www.siteguru.co.uk

  5. #5
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If this action is being initiated by a <form>, make sure you are not submitting it twice (check any validation javascript)

  7. #7
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

    Code:
    logSQLQuery = "INSERT INTO ActivityLog (ActivityLogGUID, ActivityGUID, UserGUID, AnswerFlag) VALUES('" & ActivityLogGUID & "', '" & ActivityGUID & "', '" & Session("UserGUID") & "', " & Answer & ")"
    
    Conn.Execute logSQLQuery
    Response.write logSQLQuery
    Response.End
    Query is printed only once but in database there are 2 records are inserted.
    So I am sure there is a problem with execution of Insert Query.

    Is this a SQL Bug?

  8. #8
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this a SQL Bug?
    No

    Post the entire ASP page and the page that contains the form you are submitting.

  9. #9
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Jim,

    May I mail you the pages?

  10. #10
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PM me them please

  11. #11
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jim,

    I am not able to attach the code im PM as code are so long and PM allow only 8192 characters.

  12. #12
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody have a chance to look at this??

  13. #13
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    How about save the .asp page as .txt, upload it to your site, then PM us with the link or post the link here?
    Ian Anderson
    www.siteguru.co.uk

  14. #14
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Siteguru,
    May I mail you?

  15. #15
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No. Just post a link or PM it.
    Ian Anderson
    www.siteguru.co.uk

  16. #16
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't have a live site working currently and PM allow only 8192 characters.
    That's why I am asking you to mail?

  17. #17
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,264
    Mentioned
    115 Post(s)
    Tagged
    1 Thread(s)
    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.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  18. #18
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Both the pages are attached here...

    Please help..
    Attached Files Attached Files

  19. #19
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Dave.
    I never seen this option as I am using Quick Reply always.
    I will post the code soon...

  20. #20
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,264
    Mentioned
    115 Post(s)
    Tagged
    1 Thread(s)
    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?
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  21. #21
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Set AnswerRS = Conn.Execute(SQLQuery)
    Becomes
    Conn.Execute SQLQuery
    I have tried this one previously but no luck...

  22. #22
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you getting dups on every insert, or just that one table?
    No. I have another 30-40 pages and many insert queries but they are running superbly.

    I am getting this duplicate when queries submitted to this page only...

  23. #23
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,264
    Mentioned
    115 Post(s)
    Tagged
    1 Thread(s)
    OK, but are the dups only to the ActivityLog table, or are you getting dups on the ActivityAnswers and ActivityMessages tables as well?
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  24. #24
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DaveMaxwell View Post
    OK, but are the dups only to the ActivityLog table, or are you getting dups on the ActivityAnswers and ActivityMessages tables as well?
    Yes I am getting in all the tables.
    I just can't guess the regularity of duplicates.

    Sometimes duplicates are there in ActivityLog table, sometimes in ActivityAnswers and sometimes in ActivityMessages table.

  25. #25
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •