Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Location
    Chula Vista, CA
    Posts
    4

    Unanswered: rs.addnew creates two records (HELP)

    I have tried just about everything to figure out why when adding a new record to a table, two records are inserted into the table. Here is what I have so far.
    <CONNECTION>
    Code:
    <%	
    dim conn
    dim connStr
    	
    'Create ADO Connection Component to connect to database
    Set conn = Server.CreateObject("ADODB.Connection")
    'conn.Provider = "Microsoft.Jet.OLEDB.4.0"
       connStr = "Provider=sqloledb;" & _ 
       "Data Source=(local);" & _
       "Initial Catalog=AOM;" & _
       "User Id=webuser;" & _
       "Password=webuser"
    
    conn.Open connStr
    	
    %>
    <WEB PAGE FORM>
    Code:
    <form method=post action="?action=adjGrant" onsubmit="return validate()" name="grants">
    <table border=0 cellpadding=0 cellspacing=0 width=350 align=center>
    <tr><td height=50 colspan=3 class=sbcHeader>Modify Fiscal Year Grants</td></tr>
    <tr><td colspan=3>&nbsp;</td></tr>
    <tr><td><input type=checkbox name=dailyGrant value=daily></td>
          <td>Daily Execution</td>
          <td><input type=text size=15 class=txtBoxR  name=dailyValue></td></tr>
    <tr><td><input type=checkbox name=afmGrant value=afm></td>
          <td>AFM Execution</td>
          <td><input type=text size=15 class=txtBoxR  NAME=afmType></td> </tr>
    <tr>
          <td colspan=2 height=40>&nbsp;</td>
          <td align=right><input type=submit value=Submit></td></tr>
    </table>
    </form>
    <THE ASP CODE TO ADD RECORDS>
    Code:
    dim dailyGrant
    dim dailyValue
    dim afmGrant
    dim afmValue	
    dim rsGrant
    dim strDateTime
    	
    strDateTime = getDateTime()  'Gets the current datetime format (timestamp)
                                             'for the mssql database from a function
    fy = getFiscalYear() ' Gets the current fiscal year from a function
    	
    dailyGrant = request.Form("dailyGrant")
    dailyValue = request.Form("dailyVAlue")
    afmGrant = request.Form("afmGrant")
    afmValue = request.Form("afmValue")
    
    set rsGrant = server.CreateObject("ADODB.recordset")
    rsGrant.ActiveConnection = conn
    rsGrant.CursorType = 1
    rsGrant.LockType = 3
    rsGrant.Source = "Grants"
    rsGrant.Open
    
    if(dailyGrant <> "") then
       rsGrant.AddNew
          rsGrant("fy") = fy
          rsGrant("qtr") = curQtr
          rsGrant("amount") = dailyValue
          rsGrant("type") = dailyGrant
          rsGrant("timestamp") = strDateTime	
       rsGrant.Update
    end if
    	
    if(afmGrant <> "") then
       rsGrant.AddNew
          rsGrant("fy") = fy
          rsGrant("qtr") = curQtr
          rsGrant("amount") = afmValue
          rsGrant("type") = afmGrant
          rsGrant("timestamp") = strDateTime	
       rsGrant.Update
    end if
    I just want to add one record and not two. This works with Firefox but not Internet Explorer. Is there a setting on the mysql server . I am using this code on the mysql server developer edition on my laptop running XP.

    Any help would be creatly appreciated.
    TIA

    Mike V

  2. #2
    Join Date
    Sep 2003
    Location
    Chula Vista, CA
    Posts
    4
    Finally found the answer. I knew I had a sample somewhere and I finally found my old sample. When I changed the CursorType to,

    Code:
    rsGrant.CursorType = 2   'adOpenDynamic
    It worked.

Posting Permissions

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