Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Have an ADO Recordset populated wit

Status
Not open for further replies.

vza

Programmer
Aug 1, 2003
179
US
Have an ADO Recordset populated with data from an oracle table.

I am trying to implement the find method of the recordset to find a row.
I recieve a error upon the execution of the find statement in my code which states:

"Runtime Error '-2147217879 (80040e29)
Rowset does not support scrolling backward"

I tried to correct this eror in VB and was able to do so by making my recordset cursor type adOpenStatic. (within the Open method call) This was unable to fix my VBScript code however...any ideas??

here is my code...I can't seem to figure out what is wrong. Any help would be greatly appreciated.

(VB6....altered for VBscript code)
Code:
        Dim RsFind As New ADODB.Recordset
        Dim NTAGNumber
        
        NTAGNumber = NTAGText.Text
    ' Open RecordSets
        RsFind.Open "Select * From PI_GIS", Cn
        If NTAGText.Text <> &quot;&quot; Then
             RsFind.Find &quot;Field1 = 'NTAGNumber'&quot;
                If RsFind.EOF = True Then
                    TAGText.Text = RsFind.Fields(&quot;Field2&quot;).Value
                    DESText.Text = RsFind.Fields(&quot;Field3&quot;).Value
                    LOCText.Text = RsFind.Fields(&quot;Field4&quot;).Value
                    PointText.Text = RsFind.Fields(&quot;Field5&quot;).Value
                End If
        Else
            MsgBox &quot;Specified values do not exist within the Table. Please re-insert.&quot;, vbOKOnly, &quot;Error&quot;
        End If

Thanks
-vza
 
I would skip the recordset object and the find method. Just use the connection object and criteria in your SQL statement:
set conn=createobject(&quot;ADODB.Connection&quot;)
conn.open YourConnectionString
strSql=&quot;SELECT * FROM PI_GIS WHERE Field1='NTAGNumber'&quot;
set rs=conn.execute(strSql)
If not rs.eof then
'do stuff
ELSE
'do other stuff
End if
set rs=nothing
conn.close
set conn=nothing
 
You will notice that alot of high-end dbm systems do not allow things such as .move, .previous, .absoluteposition - This is common with ORACLE, SQL, DBiii, etc...


Greg Conely
 
Hmm... doesn't look like VBScript to me:

Code:
Dim RsFind As New ADODB.Recordset

A lot of what you have here looks like VB instead of VBScript.

You need to open the Recordset with something other than the default
Code:
adForwardOnly
cursor here as well.

You also need a current row position before doing a
Code:
.Find
call. A
Code:
.MoveFirst
will take care of this as long as the Recordset isn't empty (be sure to check for both
Code:
.BOF
and
Code:
.EOF
being
Code:
True
).

Also, if
Code:
.EOF
is
Code:
True
after the
Code:
.Find
, you aren't going to have much luck pulling fields from the &quot;current row.&quot;

I agree with Veep in so far as only returning the rows you need from the database. I'm not a big fan of
Code:
<conn>.Execute
however unless all you want to do is display stuff that comes back. You end up with a woefully crippled Recordset if there is value in performing significant client manipulation of the data. The end result of this approach is repeated round-tripping to the database for stuff at different points - but it depends on what you need to do.
 
Thanks for the responses.....
Veep I have tried to implement your method but have fun into a problem....

I decided to set the field names and values to variables for many can be chosen to find on the vbScript HTML page.
I put the variables into the Cn.Execute string with everything working fine. When I test the Recordset.EOF property it is always true, even though the variable values are correct and the Cn.Execute line runs with no problems...is there something I am missing? Any help would be greatly appreciated.
Here is my code so far:
Code:
     Dim RsFind
     Dim FieldValue
     Dim Field
     Dim StrSQL

' Open RecordSets
     Set RsFind = CreateObject(&quot;ADODB.Recordset&quot;)

*** FieldValue and Field Variables set here*****

                    *******
                    *******
                    *******  

     StrSQL = &quot;Select * From PI_GIS Where '&quot; & Field & &quot;' = '&quot; & FieldValue & &quot;'&quot;
        Set RsFind = Cn.Execute(StrSQL)
        Debug.Print Field  '**Displays Correct Field**'
        Debug.Print FieldValue  '**Displays Correct Value**'
     
     If Not RsFind.EOF Then 'ALWAYS EQUALS TRUE!!!'
         NTAGText.Text = RsFind.Fields(&quot;NTAG&quot;).Value
         TAGText.Text = RsFind.Fields(&quot;TAG&quot;).Value
         DESText.Text = RsFind.Fields(&quot;DESCRIPTOR&quot;).Value
         LOCText.Text = RsFind.Fields(&quot;LOCATION2&quot;).Value
         PointText.Text = RsFind.Fields(&quot;POINTID&quot;).Value
     Else
         Exit Sub
     End If
Thanks
-vza
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top