What is the problem actually?

Discussion in 'ASP General' started by azza, Mar 28, 2007.

  1. azza

    azza Guest

    Either BOF or EOF is True, or the current record has been deleted. Requested
    operation requires a current record.
    /PROJECT/edit.asp, line 39


    <%@ LANGUAGE="JAVASCRIPT" %>
    <%
    var refer = String(Request.ServerVariables("QUERY_STRING"));
    var Item2 = refer.substring(3);
    var MM_connInviTT_STRING;
    MM_connInviTT_STRING = "Provider=Microsoft.JET.OLEDB.4.0;Data
    Source=C:/Inetpub/wwwroot/PROJECT/Record.mdb"
    var Conn = Server.CreateObject("ADODB.Connection");
    Conn.Open(MM_connInviTT_STRING);

    var sql="SELECT * FROM aktiviti WHERE activity = '" + Item2 + "'";
    var rs=Server.CreateObject("ADODB.Recordset");
    rs.Open(sql, Conn);

    if (Request("btnEdit") == "Update")
    {

    var prog= Request.Form("prog");
    var bulan=Request.Form("bulan");

    sql_update="UPDATE aktiviti SET bulan='"+bulan+"', activity='"+ prog +"'
    WHERE refer='"+Item2+"'";
    Conn.Execute(sql_update);
    rs.Close();
    rs = null;
    Conn.Close();
    Conn = null;
    Response.Redirect("editNdelete.asp");
    }
    %>

    <html><head><title>Update Detail</title></head>
    <body background="pics/red.bmp">
    <br><br><br>
    <FORM METHOD="POST" ACTION="editNdelete.asp">
    <table border=12 align="center" cellpadding=20 bgcolor="#ffcccc">
    <tr><td colspan=2><p><b><font
    color="#0000FF"><h2><center>MAKLUMAT</center></h2></font></b></p>
    </td></tr>
    <tr><td>
    <table align="center" cellspacing=15 bgcolor="#ffcccc">
    <tr><td>KOD</td><td>: <% Response.Write(rs.fields.item("refer"))%>
    </td></tr>
    <tr><td>BULAN</td><td>: <input type="text" name="bulan" size="2"
    VALUE="<% =rs.fields.item("bulan")%>"> </td></tr>
    <tr><td>PROGRAM</td><td>: <input type="text" name="prog" size="20"
    VALUE="<% =rs.fields.item("activity")%>">
    </td></tr><tr><td colspan=2 align="center"><INPUT TYPE="Submit"
    NAME="btnEdit" VALUE="Update"></td></tr>
    </td></tr></table>
    </td></tr></table>
    </FORM>
    </body>
    </html>
    azza, Mar 28, 2007
    #1
    1. Advertising

  2. azza wrote on Tue, 27 Mar 2007 18:54:37 -0700:

    > Either BOF or EOF is True, or the current record has been deleted.
    > Requested operation requires a current record.
    > /PROJECT/edit.asp, line 39
    >
    > <%@ LANGUAGE="JAVASCRIPT" %>
    > <%
    > var refer = String(Request.ServerVariables("QUERY_STRING"));
    > var Item2 = refer.substring(3);
    > var MM_connInviTT_STRING;
    > MM_connInviTT_STRING = "Provider=Microsoft.JET.OLEDB.4.0;Data
    > Source=C:/Inetpub/wwwroot/PROJECT/Record.mdb"
    > var Conn = Server.CreateObject("ADODB.Connection");
    > Conn.Open(MM_connInviTT_STRING);
    >
    > var sql="SELECT * FROM aktiviti WHERE activity = '" + Item2 + "'";
    > var rs=Server.CreateObject("ADODB.Recordset");
    > rs.Open(sql, Conn);
    >
    > if (Request("btnEdit") == "Update")
    > {
    >
    > var prog= Request.Form("prog");
    > var bulan=Request.Form("bulan");
    >
    > sql_update="UPDATE aktiviti SET bulan='"+bulan+"', activity='"+ prog +"'
    > WHERE refer='"+Item2+"'";
    > Conn.Execute(sql_update);
    > rs.Close();
    > rs = null;
    > Conn.Close();
    > Conn = null;
    > Response.Redirect("editNdelete.asp");
    > }
    > %>
    >
    > <html><head><title>Update Detail</title></head>
    > <body background="pics/red.bmp">
    > <br><br><br>
    > <FORM METHOD="POST" ACTION="editNdelete.asp">
    > <table border=12 align="center" cellpadding=20 bgcolor="#ffcccc">
    > <tr><td colspan=2><p><b><font
    > color="#0000FF"><h2><center>MAKLUMAT</center></h2></font></b></p>
    > </td></tr>
    > <tr><td>
    > <table align="center" cellspacing=15 bgcolor="#ffcccc">
    > <tr><td>KOD</td><td>: <% Response.Write(rs.fields.item("refer"))%>
    > </td></tr>
    > <tr><td>BULAN</td><td>: <input type="text" name="bulan" size="2"
    > VALUE="<% =rs.fields.item("bulan")%>"> </td></tr>
    > <tr><td>PROGRAM</td><td>: <input type="text" name="prog" size="20"
    > VALUE="<% =rs.fields.item("activity")%>">
    > </td></tr><tr><td colspan=2 align="center"><INPUT TYPE="Submit"
    > NAME="btnEdit" VALUE="Update"></td></tr>
    > </td></tr></table>
    > </td></tr></table>
    > </FORM>
    > </body>
    > </html>


    If you read your code, it's obvious what the problem is - there is no
    matching record to the Item2 variable. You should test for BOF and/or EOF
    before trying to write data from the recordset out.

    Also if you update you're closing rs, so that will cause problems too.

    Dan
    Daniel Crichton, Mar 28, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Hammond
    Replies:
    1
    Views:
    471
    Oliver
    Nov 13, 2003
  2. neverstill
    Replies:
    0
    Views:
    296
    neverstill
    Jan 6, 2004
  3. David Krussow

    Send user back to last page actually opened

    David Krussow, Jan 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    408
    Steve C. Orr [MVP, MCSD]
    Jan 29, 2004
  4. felecha
    Replies:
    3
    Views:
    2,047
    Joe Fallon
    May 3, 2004
  5. Gareth
    Replies:
    0
    Views:
    358
    Gareth
    May 13, 2004
Loading...

Share This Page