DB Problems...AddNew not supported...

Results 1 to 2 of 2

Thread: DB Problems...AddNew not supported...

  1. #1
    Join Date
    Dec 1969

    Default DB Problems...AddNew not supported...

    The code below is producing this error:<BR><BR>Object or provider is not capable of performing requested operation<BR><BR>and is pointing to rs2.AddNew<BR><BR>________________________________ <BR><BR>dim sqlCustomer, conn, rs2<BR> <BR> Set conn=Server.CreateObject("ADODB.Connection")<BR> Set rs2=Server.CreateObject("ADODB.Recordset")<BR> sqlCustomer="SELECT * FROM Customer WHERE Cust_ID=-1"<BR> conn.open("dsn=ISQS4349orlandos")<BR> rs2.open sqlCustomer,conn&#039;, adOpenKeyset, adLockPessimistic, adCmdText<BR> rs2.AddNew<BR>&#039; rs2.Fields("Cust_ID") = (9999)<BR> rs2.Fields("User_Name") = (strUserName) <BR> rs2.Fields("Password") = (strUserPassword)<BR> rs2.Update<BR> rs2.close<BR> Set rs2 = Nothing<BR>

  2. #2
    Join Date
    Dec 1969

    Default Read that FAQ!

    You can NOT comment out the adOpenKeyset, etc., etc.!!!<BR><BR>When you leave that stuff off of the OPEN, you end up with a READ-ONLY RecordSet, and *of course* you can&#039;t add a new record to something that is read only!!!<BR><BR>If you go an error from using adOpenKeyset, adLockPessimistic, adCmdText, it is because you forgot to #include "adovbs.inc". See that ASPFAQs for information on *that*, as well!<BR><BR>But I have to tell you, if you are that desparate, just go with what you had before. (INSERT and then SELECT MAX) It works. It just doesn&#039;t work if two users hit the site at the same time.<BR><BR>If you want to show your instructor that you understand the problem, then surround the code with Application.Lock/Unlock. Thus:<BR><BR>&#060;%<BR>...<BR>Application.Lock<BR >conn.Execute("INSERT INTO ... VALUES( NOW() )")<BR>Set rs = conn.Execute("SELECT MAX(CustomerID) FROM ...")<BR>MaxId = RS(0)<BR>Application.Unlock<BR>...<BR>%&#062;<BR>< BR>Note the placement of the lock and unlock! They *must* surround the *PAIR* of conn.Execute&#039;s!<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