can't edit to database error type 0x800A0E7D

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • colesslow
    New Member
    • Dec 2007
    • 8

    can't edit to database error type 0x800A0E7D

    i have these asp files to edit a record in my sql server..but it can't be done.
    the error is
    Error Type:
    ADODB.Recordset (0x800A0E7D)
    The connection cannot be used to perform this operation. It is either closed or invalid in this context.
    /testing/update22.asp, line 18
    Can anyone help me??im stuck..thanks in advance

    here's the code for update.asp

    <html>
    <body>
    <script>

    function editAll(url)
    {
    newwindow=windo w.open(url,'nam e');
    if(window.focus ){newwindow.foc us()}

    <html>
    <body>

    <h2>Update Record</h2>
    <%
    Dim connection
    Dim rsSel
    Dim sqlSel


    set Connection = Server.CreateOb ject("ADODB.Con nection")
    qid=Request("qi d")
    sqlSel="SELECT * FROM rct_HighestQual ification WHERE QualificationID = ' " & qid & "' "
    Set rsSel = Server.CreateOb ject("ADODB.rec ordset")
    rsSel.CursorLoc ation =3
    rsSel.LockType =3
    rsSel.Open sqlSel,connecti on

    connection.Open "DSN=DSNName;UI D=xxxx;PWD=xxxx ;Database=xxxx"



    if not rsSel.EOF then

    id=rsSel("id")
    name=rsSel("nam e")

    %>



    <form method="post" action="update2 2.asp" id=form1 name=form1>

    <input type=text name="id" value="<%=id%>" >
    <input type=text name="name" value="<%=name% >">

    <input type="submit" value="Update record" id=submit1 name=submit1>
    </form>
    </body>
    </html>

    <%end if
    rsSel.Close()
    set rsSel=nothing
    %>

    rsAll.Open sql,connection
    %>

    <h2>List Database</h2>
    <%
    if not rsAll.EOF then

    do while not rsAll.EOF

    id=rsAll("Quali ficationID")
    name=rsAll("Lev elOfQualificati on")
    allurl="update2 2.asp? qid=" & id
    %>
    <table>
    <tr>
    <td class="items">< %=id%></td>
    <td class="items">< %=name%></td>
    <td colspan=2 class="items">< input type="button" value="edit" onclick="editAl l('<%=allurl%>' );"></td>
    </tr>
    </table>
    <%
    rsAll.MoveNext( )
    loop
    else
    end if
    rsAll.Close()
    set rsAll=nothing
    %>

    </body>
    </html>



    and here's the code for update22.asp



    <html>
    <body>

    <h2>Update Record</h2>
    <%
    Dim connection
    Dim rsSel
    Dim sqlSel


    set Connection = Server.CreateOb ject("ADODB.Con nection")
    qid=Request("qi d")
    sqlSel="SELECT * FROM rct_HighestQual ification WHERE QualificationID = ' " & qid & "' "
    Set rsSel = Server.CreateOb ject("ADODB.rec ordset")
    rsSel.CursorLoc ation =3
    rsSel.LockType =3
    rsSel.Open sqlSel,connecti on

    connection.Open "DSN=DSNName;UI D=xxxx;PWD=xxxx ;Database=xxxx"



    if not rsSel.EOF then

    id=rsSel("id")
    name=rsSel("nam e")

    %>



    <form method="post" action="update2 2.asp" id=form1 name=form1>

    <input type=text name="id" value="<%=id%>" >
    <input type=text name="name" value="<%=name% >">

    <input type="submit" value="Update record" id=submit1 name=submit1>
    </form>
    </body>
    </html>

    <%end if
    rsSel.Close()
    set rsSel=nothing
    %>
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi colesslow,

    You've got a little bug in your code; you're trying to open your record set object, using your database connection, before you've opened the database connection itself.

    In Update22.asp simply move the line:
    Code:
    connection.Open "DSN=DSNName;UID=xxxx;PWD=xxxx;Database=xxxx"
    So it's just after the line:
    Code:
     
    set Connection = Server.CreateObject("ADODB.Connection")
    Hope this helps,

    Dr B

    Comment

    • colesslow
      New Member
      • Dec 2007
      • 8

      #3
      thanks~~
      yup..forgot to open it..

      Comment

      Working...