If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > rs.addnew creates two records (HELP)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-21-05, 13:37
mevasquez mevasquez is offline
Registered User
 
Join Date: Sep 2003
Location: Chula Vista, CA
Posts: 4
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
Reply With Quote
  #2 (permalink)  
Old 09-21-05, 15:01
mevasquez mevasquez is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On