Why this code doesn't Return PK

Results 1 to 5 of 5

Thread: Why this code doesn't Return PK

  1. #1
    ASP Guest

    Default Why this code doesn't Return PK

    To all,<BR>I got this similar code from ASP-FAQ and apply it to mine code,<BR>how come it doesn&#039;t return the PK for me. By the way I am using SQL Sever 7.0.<BR><BR> Set ObjRs = Server.CreateObject("ADODB.Recordset")<BR> <BR> ObjRs.Open "Temp_CY_48", ObjConn,1,3,2<BR> ObjRs.AddNew <BR> ObjRs("Child_CYCIS_ID")= CYCIS_ID<BR> ObjRs("Date_Of_Incident")= CDate(Date_Of_Incident)<BR> ObjRs("Oral_Report_Date")= CDate(Oral_Report_Date)<BR> ObjRs("ChildLine_Register_Number")= Child_Register_Number<BR> ObjRs("Child_Last_Name")= Child_LastName<BR> ObjRs("Child_First_Name")= Child_FirstName<BR> ObjRs("Child_MI")= Child_MI<BR> ObjRs("Child_DOB")= CDate(Child_DOB)<BR> ObjRs("Child_Sex")= Child_Sex<BR> ObjRs("Child_SSN")= Child_SSN<BR> ObjRs("Child_Address")= Child_Address<BR> ObjRs("Child_City")= Child_City<BR> ObjRs("Child_State")= Child_State<BR> ObjRs("Child_Zip")= Child_Zip<BR> ObjRs("Processing_Step")=1<BR> ObjRs.Update<BR> Response.Write (ObjRs.Fields("Form_ID"))<BR>Thanks,<BR>ASP

  2. #2
    Join Date
    Dec 1969

    Default See this faq

    last set of code at bottom should work in sql server also<BR><BR>http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=79<BR><BR>or r&d @@identity (I think anyways) using sql insert statements.

  3. #3
    Array Freak Guest

    Default RE: Why this code doesn't Return PK

    You should be using arrays

  4. #4
    ASP Guest

    Default RE: See this faq

    I told you I got the code from that FAQ site, but doesn&#039;t seem to work with mine SQL Sever 7<BR>thanks,<BR>ASP<BR>

  5. #5
    Join Date
    Dec 1969

    Default If you did

    you are not using the last code sample form that page<BR><BR>need to use correct cursor and use addnew like this:<BR><BR>rs.addnew arrFieldNames, arrFieldvalues<BR><BR>where srrFieldnames is a text array containing the fieldnames to be updated and arrFieldValues is an array containing the fieldvalues<BR>

Posting Permissions

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