Update in a repeat region problems

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Update in a repeat region problems

    I have a page which has one large table in which pulls out relevant rows from
    the database that will need updating. So i have used the update server bindings
    function and for updating 1 recors it works fine. However i want it to update
    what is pulled out of the database and because there may be more than one recor
    then i have had to use a repat region. This also work fine on its own however
    when i add the update and the repeat region together i keep getting an error.
    Can someone please help me!!!!!!!!!!!!!!!!!!!!!!!!!

    Either BOF or EOF is True, or the current record has been deleted. Requested
    operation requires a current record.

    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <!--#include file="Connections/safematrix2.asp" -->
    <%
    // *** Edit Operations: declare variables

    // set the form action variable
    var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
    if (Request.QueryString) {
    MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
    }

    // boolean to abort record edit
    var MM_abortEdit = false;

    // query string to execute
    var MM_editQuery = "";
    %>
    <%
    // *** Update Record: set variables

    if (String(Request("MM_update")) == "form3" &&
    String(Request("MM_recordId")) != "undefined") {

    var MM_editConnection = MM_safematrix2_STRING;
    var MM_editTable = "Community_Councils";
    var MM_editColumn = "council_name";
    var MM_recordId = "'" + Request.Form("MM_recordId") + "'";
    var MM_editRedirectUrl = "testrepeatShaun.asp";
    var MM_fieldsStr =
    "textfield|value|textfield2|value|textfield3|value |textfield4|value|textfield5|v
    alue|textfield6|value|textfield7|value|textfield8| value|textfield9|value|textfie
    ld10|value|textfield11|value|textfield12|value|tex tfield13|value|textfield14|val
    ue|textfield15|value|textfield16|value|textfield17 |value|textfield18|value|textf
    ield19|value|textfield192|value|textfield21|value| textfield22|value|textfield23|
    value";
    var MM_columnsStr =
    "CBM_PS|none,none,NULL|CBM|none,none,NULL|PCSO|non e,none,NULL|R_PCSO|none,none,N
    ULL|CSAS|none,none,NULL|SC|none,none,NULL|admin_su pport|none,none,NULL|CD_coordi
    nator|none,none,NULL|beat_profile|none,none,NULL|b eat_action_plan|none,none,NULL
    |CBM_CPA|none,none,NULL|CCDB|none,none,NULL|Traini ng|none,none,NULL|development_
    review|none,none,NULL|research|none,none,NULL|enga gement|none,none,NULL|public_p
    references|none,none,NULL|inv_analysis|none,none,N ULL|public_choices|none,none,N
    ULL|plan_action|none,none,NULL|review|none,none,NU LL|dyna_ddigon|none,none,NULL|
    communities_first|none,none,NULL";

    // create the MM_fields and MM_columns arrays
    var MM_fields = MM_fieldsStr.split("|");
    var MM_columns = MM_columnsStr.split("|");

    // set the form values
    for (var i=0; i+1 < MM_fields.length; i+=2) {
    MM_fields[i+1] = String(Request.Form(MM_fields[i]));
    }

    // append the query string to the redirect URL
    if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count >
    0) {
    MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") +
    Request.QueryString;
    }
    }
    %>
    <%
    // *** Update Record: construct a sql update statement and execute it

    if (String(Request("MM_update")) != "undefined" &&
    String(Request("MM_recordId")) != "undefined") {

    // create the sql update statement
    MM_editQuery = "update " + MM_editTable + " set ";
    for (var i=0; i+1 < MM_fields.length; i+=2) {
    var formVal = MM_fields[i+1];
    var MM_typesArray = MM_columns[i+1].split(",");
    var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
    var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
    var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
    if (formVal == "" || formVal == "undefined") {
    formVal = emptyVal;
    } else {
    if (altVal != "") {
    formVal = altVal;
    } else if (delim == "'") { // escape quotes
    formVal = "'" + formVal.replace(/'/g,"''") + "'";
    } else {
    formVal = delim + formVal + delim;
    }
    }
    MM_editQuery += ((i != 0) ? "," : "") + MM_columns[i] + " = " + formVal;
    }
    MM_editQuery += " where " + MM_editColumn + " = " + MM_recordId;

    if (!MM_abortEdit) {
    // execute the update
    var MM_editCmd = Server.CreateObject('ADODB.Command');
    MM_editCmd.ActiveConnection = MM_editConnection;
    MM_editCmd.CommandText = MM_editQuery;
    MM_editCmd.Execute();
    MM_editCmd.ActiveConnection.Close();

    if (MM_editRedirectUrl) {
    Response.Redirect(MM_editRedirectUrl);
    }
    }

    }
    %>
    <%
    var rs_test__var = "61100";
    if (String(Request.QueryString("myUser")) != "undefined" &&
    String(Request.QueryString("myUser")) != "") {
    rs_test__var = String(Request.QueryString("myUser"));
    }
    %>
    <%
    var rs_test = Server.CreateObject("ADODB.Recordset");
    rs_test.ActiveConnection = MM_safematrix2_STRING;
    rs_test.Source = "SELECT * FROM Community_Councils WHERE User_ID = "+
    rs_test__var.replace(/'/g, "''") + " ORDER BY ID";
    rs_test.CursorType = 0;
    rs_test.CursorLocation = 2;
    rs_test.LockType = 1;
    rs_test.Open();
    var rs_test_numRows = 0;
    %>
    <%
    var Repeat1__numRows = -1;
    var Repeat1__index = 0;
    rs_test_numRows += Repeat1__numRows;
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="community_matrix_styles.css" rel="stylesheet" type="text/css">
    <title>Untitled Document</title>
    </head>

    <body>
    <form ACTION="<%=MM_editAction%>" METHOD="POST" name="form3">
    <table width="95%" border="0" align="center" cellpadding="0"
    cellspacing="1" class="border">
    <tr class="border">
    <td width="31%" rowspan="2" class="style2"><div align="center">Test Area
    </div></td>
    <td colspan="8" class="borderleft"><div align="center">C.N.P.T</div></td>
    <td colspan="6" class="borderleft"><div
    align="center">Infrastructure</div></td>
    <td colspan="7" class="borderleft"><div
    align="center">Engagement</div></td>
    <td class="borderleft">&nbsp;</td>
    <td class="borderleft">&nbsp;</td>
    </tr>
    <tr>
    <td width="3%" bgcolor="#66FFFF"><div align="center">C<br>
    B<br>
    M<br>
    <br>
    P<br>
    S</div></td>
    <td width="3%" bgcolor="#66FFFF"><div align="center">C<br>
    B<br>
    M</div></td>
    <td width="3%" bgcolor="#66FFFF"><div align="center">P<br>
    C<br>
    S<br>
    O</div></td>
    <td width="3%" bgcolor="#FFCC66"><div align="center">R<br>
    <br>
    P<br>
    C<br>
    S<br>
    O</div></td>
    <td width="3%" bgcolor="#FFCC66"><div align="center">C<br>
    S<br>
    A<br>
    S</div></td>
    <td width="3%" bgcolor="#FFCC66"><div align="center">S<br>
    C</div></td>
    <td width="3%" bgcolor="#FFCC66"><div align="center">A<br>
    d<br>
    m<br>
    i<br>
    n<br>
    <br>
    S<br>
    u<br>
    p<br>
    p<br>
    o<br>
    r<br>
    t </div></td>
    <td width="3%" bgcolor="#FFCC66"><div align="center">C<br>
    D<br>
    <br>
    C<br>
    o<br>
    o<br>
    r<br>
    d<br>
    i<br>
    n<br>
    a<br>
    t<br>
    o<br>
    r</div></td>
    <td width="3%" bgcolor="#66FF66"><p align="center">B<br>
    e<br>
    a<br>
    t<br>
    <br>
    P<br>
    r<br>
    o<br>
    f<br>
    i<br>
    l<br>
    e </p></td>
    <td width="3%" bgcolor="#66FF66"><div align="center">B<br>
    e<br>
    a<br>
    t<br>
    <br>
    A<br>
    c<br>
    t<br>
    i<br>
    o<br>
    n<br>
    <br>
    P<br>
    l<br>
    a<br>
    n</div></td>
    <td width="3%" bgcolor="#66FF66"><div align="center">C<br>
    B<br>
    M<br>
    <br>
    C<br>
    P<br>
    A</div></td>
    <td width="3%" bgcolor="#66FF66"><div align="center">C<br>
    C<br>
    D<br>
    B</div></td>
    <td width="3%" bgcolor="#66FF66"><div align="center">T<br>
    r<br>
    a<br>
    i<br>
    n<br>
    i<br>
    n<br>
    g</div></td>
    <td width="3%" bgcolor="#66FF66"><div align="center">D<br>
    e<br>
    v<br>
    e<br>
    l<br>
    o<br>
    p<br>
    m<br>
    e<br>
    n<br>
    t<br>
    <br>
    R<br>
    e<br>
    v<br>
    i<br>
    e<br>
    w<br>
    </div></td>
    <td width="3%" bgcolor="#FFFF66"><div align="center">R<br>
    e<br>
    s<br>
    e<br>
    a<br>
    r<br>
    c<br>
    h</div></td>
    <td width="3%" bgcolor="#FFFF66"><div align="center">E<br>
    n<br>
    g<br>
    a<br>
    g<br>
    e<br>
    m<br>
    e<br>
    n<br>
    t</div></td>
    <td width="3%" bgcolor="#FFFF66"><div align="center">P<br>
    u<br>
    b<br>
    l<br>
    i<br>
    c<br>
    <br>
    P<br>
    r<br>
    e<br>
    f<br>
    e<br>
    r<br>
    e<br>
    n<br>
    c<br>
    e<br>
    s</div></td>
    <td width="3%" bgcolor="#FFFF66"><p align="center">I<br>
    n<br>
    v<br>
    <br>
    &amp;<br>
    <br>
    A<br>
    n<br>
    a<br>
    l<br>

    elenton Guest

  2. Similar Questions and Discussions

    1. Update record inside a repeat region
      Hello All, I created an update record that I converted to a horizontal line and added a repeat region into it. The page actually load up showing...
    2. Flash repeat region
      i urgently need to do the following: haveing never tucked into putting dynamic data into flash, i suddenly, urgently need to dynamically populate...
    3. download repeat region
      Hi, I used the download repeat region on a site I set up a while ago, it worked great then. My customer has told me it no longer works, instead...
    4. repeat region
      Hi.. I use repeat region to view only 10 records at a time, so how can I have another link that when user click on next it will go to another 10 of...
    5. php repeat region
      Hey guys, question about PHP, I'm trying to help out a friend but I don't really know anything about php. I'm also pretty amaturish at asp. I...
  3. #2

    Default Re: Update in a repeat region problems

    so...

    are you trying to update multipule entries with one update button?

    does each entry have its own update button?

    as far as i know, you can change multipule records in the same form tat are
    going into the same columns as the parser gets mixed up which one has been
    updated.

    you should have a unique column so that one record is displayed.

    why dont you display all the results with a repeat region, THEN have a GO TO
    DETAIL page which will update that specific record?

    Don Pacino Guest

  4. #3

    Default Re: Update in a repeat region problems

    hav alook at this

    [url]http://www.drdev.net/article11.asp[/url]
    Don Pacino Guest

  5. #4

    Default Re: Update in a repeat region problems

    Thanks have just been looking that that example and in the process of trying to make it work if i get stuck though might be back.
    elenton Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139