Do you not need to requery before getting the ID back?

objRSreferadd.Update
intr = objRSreferadd("ReferrerID")
objRSreferadd.Requery

I usually use "SELECT @@Identity" to return the primary of a new record added, but I 
guess that's just a personal way of working.

Dan
www.diado.com

-----Original Message-----
From: Martin Brown [mailto:[EMAIL PROTECTED]
Sent: 25 August 2004 11:04
To: [EMAIL PROTECTED]
Subject: [AspClassicAnyQuestionIsOk] Record insert error


Hi

I do this all the time and have never had a problem so I'm going insane
looking for my error.
I add a record to a SQL Server database and I need the record ID back.
No errors are produced but when I response.write the record id's there is
nothing output which is causing later code to fail
I have checked the database - the field is an identity field and the records
are being inserted with new id fields - so why isn't it returning a
value????

Code:

                        dim objRSreferadd
                        set
objRSreferadd=Server.CreateObject("ADODB.recordset")
                        objRSreferadd.open "tblCrmeBayReferrer", objConn,
adOpenKeyset, adLockPessimistic, adCmdTableDirect
                        objRSreferadd.AddNew
                        objRSreferadd.Fields("ReferrerName") =
objRSreferrals("YourName")
                        objRSreferadd.Fields("ReferrerEmail") =
objRSreferrals("YourEmail")
                        objRSreferadd.Fields("ReferrereBayID") =
objRSreferrals("YoureBayID")
                        objRSreferadd.Update
                        intr = objRSreferadd("ReferrerID")
                        response.write "Referrer ID = " & intr & "<br>"
Cheers
Martin


________________________________________________________________________
This e-mail and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
This communication may contain confidential material. If you are not the
intended recipient or the person responsible for delivering the email to the
intended recipient, be advised that you have received this email in error
and that any use, dissemination, forwarding, printing, or copying of this
email is strictly prohibited. If you have received this email in error,
please notify the sender. 
The statements and opinions expressed in this message are those of the
author and do not necessarily reflect those of the company. The company does
not take any responsibility for the views of the author.
As internet communications are not secure we do not accept legal
responsibility for the contents of this message nor responsibility for any
change made to this message after it was sent by the original sender. We
advise you to carry out your own virus check before opening any attachment
as we cannot accept liability for any damage sustained as a result of any
software viruses.



[Non-text portions of this message have been removed]


Yahoo! Groups Sponsor
ADVERTISEMENT






Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
  
To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
  
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to