Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004
    Posts
    3

    Unanswered: HELP with Updating a record

    I am trying to be able to view a record and then update it. I can get it to view, but the update doesn't work. Here is my code. Can anyone help me?
    <%
    Dim MyConn, RS, word1
    word1 = Request("word1")
    Set MyConn = Server.CreateObject("ADODB.Connection")
    Set RS = Server.CreateObject("ADODB.RecordSet")
    MyConn.Mode = adModeReadWrite
    MyConn.Open ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + Server.MapPath("geagents.mdb"))

    RS.Open "SELECT * FROM agents where "&_
    "id like '%" & word1 & "%';",MyConn

    %>
    <form name="form1" method="post" action="update.asp">

    <TABLE width="750" align="center">
    <TR valign="bottom">
    <TD colspan="7" height="62">
    <div align="center">
    <p><font face="Arial, Helvetica, sans-serif" size="4">LTC Consumer Website
    </font></p>
    <p>&nbsp;</p>
    </div>
    </TD>
    </TR>
    <TR valign="bottom">
    <TD colspan="7" height="17">
    <div align="center"><font face="Arial, Helvetica, sans-serif">Current
    information is as shown: </font> </div>
    <table width="100%" border="0" cellpadding="0">
    <tr>
    <td colspan="7">&nbsp;</td>
    </tr>
    <tr> <input type="hidden" name="RID" value="<%=word1%>">
    <td width="17%"><font face="Arial, Helvetica, sans-serif" size="2">ID/Agent
    Name<br>
    Domain </font></td>
    <td width="24%"><font face="Arial, Helvetica, sans-serif" size="2">Address<br>
    City, State, Zip</font></td>
    <td colspan="2">
    <p><font face="Arial, Helvetica, sans-serif" size="2">Compliance
    Contact &amp; Email</font></p>
    <font face="Arial, Helvetica, sans-serif" size="2"></font></td>
    <td width="8%"><font face="Arial, Helvetica, sans-serif" size="2">Status</font></td>
    <td width="12%"><font face="Arial, Helvetica, sans-serif" size="2">Approval
    Date</font></td>
    <td width="15%"><font face="Arial, Helvetica, sans-serif" size="2">Notes</font></td>
    </tr>
    <tr>
    <td width="17%"><font face="Arial, Helvetica, sans-serif" size="2"><%=rs("id") & ""%><%=rs("name") & ""%><br>
    <%=rs("url") & ""%><br>
    </font></td>
    <td width="24%"><font face="Arial, Helvetica, sans-serif" size="2"><%=rs("address") & ""%><br>
    <%=rs("city") & ""%><%=rs("state") & ""%><%=rs("zip") & ""%></font></td>
    <td colspan="2"><font face="Arial, Helvetica, sans-serif" size="2"><%=rs("compperson") & ""%><br>
    <%=rs("compemail") & ""%></font><font face="Arial, Helvetica, sans-serif" size="2"></font></td>
    <td width="8%"><font face="Arial, Helvetica, sans-serif" size="2"><%=rs("status") & ""%></font></td>
    <td width="12%"><font face="Arial, Helvetica, sans-serif" size="2"><%=rs("appdate") & ""%></font></td>
    <td width="15%"><font face="Arial, Helvetica, sans-serif" size="2"><%=rs("notes") & ""%><%
    RS.Close
    Set RS = Nothing
    MyConn.Close
    Set MyConn = Nothing %>
    </font></td>
    </tr>
    </table>
    </TD>
    </TR>
    <TR valign="bottom">
    <TD colspan="7" height="43">
    <div align="center"><font face="Arial, Helvetica, sans-serif" size="4">Edit
    the information as it should be seen and click on update</font></div>
    </TD>
    </TR>
    <TR>
    <TD bgcolor="#F3F5FD" width="175" height="223"><font face="Arial, Helvetica, sans-serif" size="2">
    </font>
    <table width="800" border="0" cellpadding="0">
    <tr>
    <td width="76"><font face="Arial, Helvetica, sans-serif" size="2">ID</font></td>
    <td width="240"><font face="Arial, Helvetica, sans-serif" size="2">
    <input type="text" name="ID">
    </font></td>
    <td width="131"><font face="Arial, Helvetica, sans-serif" size="2">Agent
    Name:</font></td>
    <td width="343"><font face="Arial, Helvetica, sans-serif" size="2">
    <input type="text" name="name">
    </font></td>
    </tr>
    <tr>
    <td width="76"><font face="Arial, Helvetica, sans-serif" size="2">Domain:</font></td>
    <td width="240"><font face="Arial, Helvetica, sans-serif" size="2">
    <input type="text" name="url">
    </font></td>
    <td width="131">Address: </td>
    <td width="343">
    <input type="text" name="address" size="40">
    </td>
    </tr>
    <tr>
    <td width="76">City: </td>
    <td width="240">
    <input type="text" name="city">
    </td>
    <td width="131">State:</td>
    <td width="343">
    <input type="text" name="state" size="4">
    Zip
    <input type="text" name="zip" size="10">
    </td>
    </tr>
    <tr>
    <td rowspan="2">Compliance Contact:</td>
    <td rowspan="2">
    <input type="text" name="compperson">
    <br>
    </td>
    <td width="131" rowspan="2">Compliance Contact Email:</td>
    <td width="343" rowspan="2">
    <input type="text" name="compemail">
    </td>
    </tr>
    <tr> </tr>
    <tr>
    <td width="76">Status:</td>
    <td width="240">
    <input type="text" name="status">
    </td>
    <td width="131">Approval Date: </td>
    <td width="343">
    <input type="text" name="appdate">
    </td>
    </tr>
    <tr>
    <td width="76">Notes: </td>
    <td colspan="3">
    <input type="text" name="notes" size="100">
    </td>
    </tr>
    </table>
    <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">
    </font> </div>
    </TD>
    </TR>
    </table>


    <table width="750" border="0" cellpadding="0" align="center">
    <tr>
    <td width="750" height="5">
    <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">
    <input type="submit" name="Submit" value="Update Record">
    <%
    Dim Conn, MRS, RID
    RID = Request("word1")
    Set Conn = Server.CreateObject("ADODB.Connection")
    Set MRS = Server.CreateObject("ADODB.RecordSet")
    Conn.Mode = adModeReadWrite
    Conn.Open ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + Server.MapPath("geagents.mdb"))

    sql = "UPDATE agents SET name = '" & request.form("name") & "', address = '" & request.form("address") & "', city = '" & request.form("city") & "', state = '" & request.form("state") & "', zip = '" & request.form("zip") & "', compperson = '" & request.form("compperson") & "', compemail = '" & request.form("compemail") & "', status = '" & request.form("status") & "', appdate = '" & request.form("appdate") & "', notes = '" & request.form("notes") & "' where "&_
    "id like '%" & RID & "%';"


    Conn.Close
    Set Conn = Nothing
    %>
    </font></div>
    </td>
    </tr>
    <tr>
    <td width="750" height="5">
    <hr noshade>
    </td>
    </tr>
    <tr>
    <td height="39" valign="top">
    <div align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">Copyright
    &copy; 1999-2004, LTC Connection. All Rights Reserved.<br>
    Disclaimer </font></div>
    </td>
    </tr>
    </table>
    </form>

  2. #2
    Join Date
    Jul 2004
    Posts
    3
    Hi,
    Maybe it would be a good idea to place the updating code into a separate ASP page and when the update is done, then redirecting the response to the original page.
    If you have not received any error message, then I think that the update was successful after the POST, but you could not see it on the page since during the process first your select statement runs and only after that you run the UPDATE statement. If you are not willing to move the UPDATE statement into a separate ASP, then I would recommend to have first the UPDATE section in your code ( and it should only run after a POST ) and then have the SELECT section.

    rgds

Posting Permissions

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