problem with addnew method

Results 1 to 2 of 2

Thread: problem with addnew method

  1. #1
    Join Date
    Dec 1969

    Default problem with addnew method

    I&#039;ve got a record on one server that I need to copy to another server. I&#039;ve tried to run a query such as Insert into table (field1, field2) select field1, field2 where userID = userID, but because of having over 50 different fields that we&#039;re adding, I&#039;m getting some invalid use of null errors that have been nearly impossible to track down. So, for the time being, I&#039;ve resorted to the old rs.addnew method. So, what I do is create a recordset from server1 with the record I need. Then connect to server 2 adn create a recordset there, call the addnew method, fill in the fields with their values and call update. I don&#039;t see any problem with the code and when I print out the values that I&#039;m trying to input, the data is there. But when I open enterprise manager and run a query on my table to see if the record was created, it wasn&#039;t. Anyone have any idea what could be happening? Thanks. Here&#039;s a bit of my code.<BR><BR><BR>set conn = NominationConnect()<BR>set conASP = connectToASP()<BR>userID = trim(request.form("userID"))<BR><BR>sql = "SELECT Comment,<BR><BR>... <BR><BR>from Candidate where userID = &#039;"& userID &"&#039;"<BR><BR> set crRS = conn.execute(sql)<BR> if not crRS.eof then<BR> <BR> set newRS = server.createobject("adodb.recordset") <BR> "People", conASP,adopenkeyset,adlockoptimistic,adCmdTable<BR ><BR> newRS.addnew<BR><BR> &#039;add new fields<BR> newRS.fields("AgencyID") = session("agencyID")<BR><BR> ....<BR><BR> newRS.update<BR> newRS.close<BR> set newRS = nothing<BR> end if<BR><BR>disconnect (conASP)<BR>disconnect (conn)<BR>response.write "candidate information successfully written."

  2. #2
    Join Date
    Dec 1969

    Default Ummm...

    &#062; newRS.fields("AgencyID") = session("agencyID")<BR><BR>Ummm...where did that Session variable come from???<BR><BR>How will AddNew get you over the NULL problem??? If the field is null in the "from" DB, and the "to" DB doesn&#039;t allow nulls, then you&#039;re *still* going to get the error, even using AddNew, aren&#039;t you???<BR><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