It keep updating the same record

Results 1 to 2 of 2

Thread: It keep updating the same record

  1. #1
    Join Date
    Dec 1969

    Default It keep updating the same record

    hai good evening,<BR>i have this problem my system keep updating the same record even though i&#039;m actually editing other record...plz help me .<BR>below is my coding<BR>regards<BR>renu<BR><BR><BR>&#060;!--METADATA TYPE="typelib"<BR> &#039; File="C:Program FilesCommon FilesSystemadomsado15.dll"--&#062;<BR><BR><BR>&#060;% <BR> Set strCon =Server.CreateObject("ADODB.Connection")<BR><BR> strCon.Open ="Provider=SQLOLEDB;Persist Secruity Info =False;"&_<BR> "User ID=sa ;Initial Catalog=PIS;"&_<BR> "Initial File Name=C:MSSQL7DataPIS_Data.mdf"<BR> <BR> <BR> set rsCat=Server.CreateObject("ADODB.RecordSet")<BR><B R>sql="Select *from Product where Brand_name=&#039;"&Request.Form("bn")&"&#039;"<BR> <BR>rsCat.Open sql,strCon ,adOpenDynamic,adLockOptimistic,adCmdTable<BR><BR> <BR>rsCat("Sub_class")=Request.Form("sb")<BR><BR>r sCat("Price")=Request.Form("pri")&#039;<BR>rsCat(" Class")=Request.Form("cls")<BR>rsCat("Status")=Req uest.Form("sta")<BR>rsCat("Presentation")=Request. Form("pres")<BR>rsCat("Generic_name")=Request.Form ("gn")<BR>rsCat("Content")=Request.Form("cn")<BR>r sCat("indication")=Request.Form("ind")<BR>rsCat("d osage")=Request.Form("dos")<BR>rsCat("contradictio n")=Request.Form("con")<BR>rsCat("special_precauti on")=Request.Form("sp")<BR>rsCat("adverse_reaction ")=Request.Form("ad")<BR>rsCat("interaction")=Requ est.Form("int")<BR>rsCat("Poison_class")=Request.F orm("pc")<BR>rsCat("Manufacturer_id")=session("reg No")<BR>rsCat.Update<BR>%&#062;<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Minor oops leads to bigger one...

    You have a contradiction in your code:<BR><BR>First: you create a SQL statement:<BR>sql="Select *from Product where Brand_name=&#039;"&Request.Form("bn")&"&#039;"<BR> <BR>But then you tell the OPEN command to ignore the SQL and only open the *TABLE*:<BR>rsCat.Open sql,strCon ,adOpenDynamic,adLockOptimistic,adCmdTable<BR><BR> Because that is what "adCmdTable" means: Open a single table.<BR><BR>If you wanted to actually *use* the SQL statement, you needed to use adCmdStmt [I think? Well.. if you just leave it off, completely, it does the right thing automatically!]<BR><BR>Anyway, if all you do is keep opening the table, then of course the updates will all apply to the first record of the table, over and over.<BR><BR>So try<BR><BR>rsCat.Open sql, strCon, adOpenDynamic, adLockOptimistic<BR><BR>NOTE: Now, you will *still* be getting *all* the records that have the given Brand_Name, so if there is more than one such record, that code will only change the *first one*. If that&#039;s a problem, then you need to redesign the query to try to pick just a single record.<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