Results 1 to 8 of 8

Thread: Weird error..

  1. #1
    Join Date
    Jan 2004
    Posts
    27

    Unanswered: Weird error..

    Hi,

    I'm trying to connect to oracle from asp pages with IIS using oracle odbc drivers. i managed to connect to it, and i've created a test table, but something is wrong and i need to know why...

    <%@ Language=VBScript %>
    <html>
    <head>
    <title>Oracle Test</title>
    </head>
    <body>
    <center>
    <%
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open "dsn=OracleDSN;uid=system;pwd=manager;"

    Set objRs = objConn.Execute("SELECT * FROM test ORDER BY id ASC")

    Response.Write "<table border=1 cellpadding=4>"
    Response.Write "<tr>"

    For I = 0 To objRS.Fields.Count - 1
    Response.Write "<td><b>" & objRS(I).Name & "</b></td>"
    Next

    Response.Write "</tr>"

    'objRS.movefirst

    Do While Not objRS.EOF
    Response.Write "<tr>"

    For I = 0 To objRS.Fields.Count - 1
    Response.Write "<td>" & I & " " & objRS(I).Value & "</td>"
    Next

    Response.Write "</tr>"

    objRS.MoveNext
    Loop

    Response.Write "</table>"

    objRs.Close
    objConn.Close
    %>
    </center>
    </body>
    </html>

    up there is the code that i used, and i've created the table using this:

    create table test ( id number(8), name char(150) );

    if you've noticed this line: 'objRS.movefirst
    i hide it cos i can't call that method and i wonder why... i get this error:

    Error Type:
    ADODB.Recordset (0x800A0BCD)
    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

    yeah i have something to clarify here: without that movefirst method, it showed the page without errors but i couldn't see any records at all. I've inserted some records in the database already!


    please advice!!
    Last edited by jacky_cheecheo; 03-30-04 at 18:02.
    Warm Regards,
    Jacky

  2. #2
    Join Date
    Mar 2004
    Posts
    3
    That error means that you have reached the end of the database without any results. Try to add records to the database, check your code and try again.

    It's probably not a syntax error, rather the way your reading through the database.

  3. #3
    Join Date
    Dec 2003
    Posts
    454
    Before you retrieve data from the record set, you need to check if the record set is empty.

    <%
    If Not RS.BOF Or Not RS.BOF Then
    ' do something here
    End If
    %>

  4. #4
    Join Date
    Mar 2004
    Posts
    3
    I think you mean RS.EOF

  5. #5
    Join Date
    Dec 2003
    Posts
    454
    Sorry mistyping.

    <%
    If Not RS.BOF Or Not RS.EOF Then
    ' do something here
    End If
    %>

  6. #6
    Join Date
    Jan 2004
    Posts
    27
    ok nvm that problem...i solved it already, thanks for the help...

    however, i was wondering why i couldn't use rs.moveprevious, the error that i'm getting is:

    Operation is not allowed in this context
    Warm Regards,
    Jacky

  7. #7
    Join Date
    Dec 2003
    Posts
    454
    You need to open a record set with the dynamic cursor which supports forward and backword navigation in your record set.

    Dim adOpenDynamic : adOpenDynamic = 2
    Set objRS = Server.CreateObject("ADODB.RecordSet")
    objRS.Open "SELECT * FROM test ORDER BY id ASC", objConn, adOpenDynamic

  8. #8
    Join Date
    Jan 2004
    Posts
    27
    oh yes, how could i not thought of that....
    thanks for the reply!
    Warm Regards,
    Jacky

Posting Permissions

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