1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Problem when adding record

Discussion in 'C#' started by trp, Apr 11, 2006.

  1. #1
    Hello!

    I have a problem when adding records. It always adds the record twice. So I get 2 entries in the db.
    Tried many diverent things. When I use .Add I still get two entries.
    Can any body help?

    thx trp
    SEMrush
    edit: The problem only exists when I use Internet Explorer. If I use Firefox it works fine. (testet at different computers)

    File with form
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    </head>
    <body>
    
            <form method="POST" name="form_hinzufuegen20" action="process/Reviewing.asp">
              <textarea rows="5" name="TextNeu" cols="50" class="field"></textarea>
              <input type="hidden" name="Process" value="Hinzufuegen">
              <input type="hidden" name="PflanzeID" value="1">
              <input type="hidden" name="FeldName" value="20">
              <input name="New" onClick="document.form_hinzufuegen20.submit()" type="image" src="img/save15px.gif" BORDER="0" width="15" height="15">
            </form>
            
    </body>
    </html>
    Code (markup):
    Reviewing.asp
    
    <%
    '###############
    ' Request Variables
    '###############
      PflanzeID = Request("PflanzeID")
      Process = Request("Process")
      strMessage = Request("TextNeu")
      FeldName = Request("FeldName")
    
    if Process="Hinzufuegen" then
    
    '----------- Connection-Objekt instanziieren
     set conn = server.CreateObject("ADODB.Connection")
     strConn = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;"
     strConn = strConn & "Data Source=" & server.MapPath("../../fpdb/") & "/db1.mdb;"
    '----------- Connection öffnen
     conn.Open strConn
     strInsert = "INSERT INTO tblReview (PflanzeID, ReviewActiv, FeldName, ReviewTXT, Autor, aktuellerEditor ) VALUES ('" & PflanzeID & "', True, '" & FeldName & "', '" & strMessage & "', '1', '2')"
    '----------- Datensatz hinzufügen
     conn.Execute strInsert
    '----------- Objekte zerstören
    set conn = nothing
    
    end if
    %>
    Code (markup):
     
    trp, Apr 11, 2006 IP
    SEMrush
  2. jaymcc

    jaymcc Peon

    Messages:
    139
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You aren't using IE7 by chance are you?

    I had a perfectly working form that inserted as expected in IE6, went to 7 and had double entries also. FIrefox worked fine, went back to IE6 and it all works. Buggy!

    J
     
    jaymcc, Apr 11, 2006 IP
  3. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #3
    looks like you're using access - and not only that, frontpage. guessing from the line that reads
    i have seen this sort of double-submit thing happen NUMEROUS times using fp/access. not sure if it's the frontpage side, or the access side... but i've definitely seen it numerous times. That's one of the reasons why i switched over to MYSQL a while back - and i haven't seen it happen since.

    I don't personally see anything in your code that is throwing this out, but if you're seriously concerned, you might try putting a bit of code in after the insert query to check to see if it was double-submitted, and delete the second row if it was.
     
    vectorgraphx, Apr 11, 2006 IP
  4. trp

    trp Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi jaymcc,

    thx for your answer. No I'm using IE6. Didn't try IE7 up to now.
    The code was just cecked by a friend of mine and he found the problem.

    Removed onClick="document.form_hinzufuegen20.submit()" from <input name="New" onClick="document.form_hinzufuegen20.submit()" type="image" src="img/save15px.gif" BORDER="0" width="15" height="15"> and now it works properly.

    trp
     
    trp, Apr 11, 2006 IP
  5. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #5
    cool - glad you sorted it out
     
    vectorgraphx, Apr 11, 2006 IP