<<<<< UPDATE CODE >&

Results 1 to 3 of 3

Thread: <<<<< UPDATE CODE >&

  1. #1
    LEAR Guest

    Default <<<<< UPDATE CODE >&

    Hey there folks.... I am currently trying to update records to a table. There are existing records and I want to edit them from a form, submit that and then overwirte the existing ones... Can anyone help with the update code???<BR><BR>This is the code in the form...<BR><BR>&#060;%<BR>dim oConnection, oRecordset, strSQL, Addnew<BR>const adOpenStatic = 3<BR>const adLockOptimistic = 3<BR>set oConnection = Server.CreateObject("ADODB.Connection")<BR>oConnec tion.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _<BR>& "Data Source=" & Server.Mappath("cpo.mdb")<BR>strSQL = "SELECT * FROM tblprojects"<BR>set oRecordset = Server.CreateObject("ADODB.Recordset")<BR>oRecords et.Open strSQL, oConnection, adOpenStatic, adLockOptimistic<BR>oRecordset.Addnew<BR>oRecordse t("proname") = Request.Form("textproname")<BR>oRecordset("sumpro" ) = Request.Form("textsumpro")<BR>oRecordset("prospon" ) = Request.Form("textprospon")<BR>oRecordset("proteam ") = Request.Form("textproteam")<BR>oRecordset("duedate ") = Request.Form("textduedate")<BR>oRecordset("update" ) = Request.Form("textupdate")<BR>oRecordset("protar") = Request.Form("proicon")<BR>oRecordset.Update<BR>oR ecordset.close<BR>oConnection.Close<BR><BR>&#039;r esponse.redirect "index.htm target=""parent"""<BR><BR>%&#062; <BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: <<<<< UPDATE CODE �

    &lt;harmless sacrasm&gt;First off, you are using oRecordset.Addnew - surprising as this may sound, that will ADD a new record, and not UPDATE an existing record (I know, crazy). &lt;/harmless sacrasm&gt;<BR><BR>It would be much much much much much better to do this:<BR><BR>dim oConnection, strSQL<BR>const adOpenStatic = 3<BR>const adLockOptimistic = 3<BR><BR>set oConnection = Server.CreateObject("ADODB.Connection")<BR>oConnec tion.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _<BR>& "Data Source=" & Server.Mappath("cpo.mdb")<BR>strSQL = "UPDATE tblprojects SET proname=&#039;" & Request.Form("textproname") & "&#039;, sumpro=&#039;" & Request.Form("textsumpro")<BR> & "&#039;"<BR><BR>oConnection.Execute strSQL<BR><BR>(note, you will have to extend the UPDATE SQL to update the rest of the fields in your DB).

  3. #3
    LEAR Guest

    Default RE: <<<<< UPDATE CODE �

    I can deal with harmless sarcasam if it works!!! I&#039;m a novice at the ASP game... I had copied the code from elsewhere hence silly Addnew comment... Thank you millions Kurt

Posting Permissions

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