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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error reading recordset

Status
Not open for further replies.

Chopstik

Technical User
Oct 24, 2001
2,180
US
I have created a VB .dll file that accesses a database and returns all of the records within a given table. The function works as I have tested it successfully inside of a separate VB app.

Now, I am trying to instantiate this inside of an ASP page and simply show the records on the screen. However, I keep receiving an error message and it will not run. The error appears to be where I'm calling the specific function (recordset) and then trying to use it's properties/methods. It doesn't appear to recognise the recordset and thus returns no data. Furthermore, it halts running any further code after that point (HTML or otherwise). Below is a copy of my ASP code, can anyone see the problem? (Incidentally, this code is copied directly out of ASP 3.0 book by Wrox Press - so it should work.)

<%@ Language=VBScript TRANSACTION=Required %>
<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
</HEAD>
<BODY>
<FORM ID=&quot;frmOrder&quot; NAME=&quot;frmOrder&quot; ACTION=&quot;PlaceOrder.asp&quot; METHOD=&quot;Post&quot;>
<BLOCKQUOTE>
<H3>
To generate an order enter in your first name, last name,
the quantity, and select a product to purchase.
</H3>
<HR>
<BR>

First Name:
<BR>
<INPUT TYPE=&quot;text&quot; ID=&quot;txtFN&quot; NAME=&quot;txtFN&quot;>
<P>

Last Name:
<BR>
<INPUT TYPE=&quot;text&quot; ID=&quot;txtLN&quot; NAME=&quot;txtLN&quot;>
<P>

Products:
<BR>
<SELECT ID=&quot;optProducts&quot; NAME=&quot;optProducts&quot;>
<%
dim objASPTrans, rsProducts
set objASPTrans = server.CreateObject(&quot;ASPTrans.Products&quot;)
rsProducts = objASPTrans.GetProducts

do until rsProducts.eof
Response.Write &quot;<OPTION VALUE=&quot; & rsProducts(&quot;id&quot;) & _
&quot;>&quot; & rsProducts(&quot;name&quot;) & vbCrLf
rsProducts.movenext
loop

set rsProducts = nothing
set objASPTrans = nothing
%>
</SELECT>
<P>

Quantity:
<BR>
<INPUT TYPE=&quot;text&quot; ID=&quot;txtQuantity&quot; NAME=&quot;txtQuantity&quot;>
<P>

<INPUT TYPE=&quot;submit&quot; VALUE=&quot;Place Order&quot; ID=&quot;btnPlaceOrder&quot; NAME=&quot;btnPlaceOrder&quot;>
</BLOCKQUOTE>
</FORM>
</BODY>
</HTML>
 
try adding 'set' to the recordset line.

set rsProducts = objASPTrans.GetProducts
codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
<insert witticism here>
 
I had actually done that originally and still not produced any results. My error line (when viewing the source code from the page since no error actually pops up on the page) says that there is &quot;Error, object required&quot; for this line. What looks to be happening is that it is not recognising the recordset in ASP. I know in my component that everything is set to be a recordset, just don't know why it's not recognising a recordset within my ASP page. :(
 
at which point are you connecting to the DB and opening the recordset?
This may be a different way then I've seen using a recordset in a asp but I can't seem to see where the DB is actually accessing the set. what does the error read.
codestorm is correct in the &quot;set&quot;. it should be where you set the recordset. I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
The code to open the db and connect to the recordset is actually in the component itself. I open directly to the recordset, establish that the value of the component is equal to the value of the recordset and then go from there. I should point out that I am using a disconnected recordset, but there should not be an issue with this. When I use the component in another VB app, it works as it should. The error appears to be with calling it from within ASP. Also, this code is copied directly from a sample in one of my ASP books. (I originally had &quot;set&quot; in my code, then took out it out for one of the tests I was using to figure out my problem. I simply forgot to include it in with the code I pasted here.)

Also, the page does not read an error message. It simply stops processing at the point where it looks for the recordset. I know this because I have HTML code after this piece of VBS that is not processed. The only error message I get is when I actually go in to look at the source code of the page itself. The work is at my office and won't be able to print the &quot;exact&quot; message until Monday, but it boils down to &quot;Object required&quot; and the line it occurs on is &quot;do until rsProducts.eof&quot;. This problem is really frustrating me, especially considering this is just a test of a sample that is pulled directly from a Wrox book.

Don't know if it makes a difference or not, but this is running off of a NT 4.0 server running IIS 4.0. My development system is 2000, but not sure if that makes a difference in any way. Thanks for all of your help!
 
I'm sure you did this already - but an error I made when including dll's with ASP pages is that you have to &quot;register&quot; them first. Windows needs to know where the dll is so it can use it.

I don't have the code in front of me to register a dll, but when I find it I will post it. Einstein47
(How come we never see the headline, &quot;Psychic Wins Lottery&quot;?)
 
ok, couple of things ..
1. regsvr32 <path and filename of DLL> at a command prompt will register a DLL, however given the error I believe you've already done that.
2. I assume your objASPTrans.GetProducts function returns an ADODB.Recordset object?
3. In this case I'd assume that it's taking exception to the disconnected nature of it - not liking passing a disconnected recordset as a function output, or some such.
Instead of returning a disconnected recordset from the function, try whacking the recordset in an array (GetRows) and passing that back to use in ASP. codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
<insert witticism here>
 
Ok, I had registered it (and that in itself was a learning curve that took me a day to figure out early last week - LOL). I thought about the disconnected recordset being the issue, but dismissed the idea because it worked in my VB test. However, maybe there's something with it being in ASP that is causing the issue. I don't know. I'll conduct a test tomorrow when I go into work and see what happens. I'll post and let you know what happens. Thanks for all you guys help!
 
Here is a copy of the source code (with the error message inside at the end). Don't know if this will help, but still plugging away at it.

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
</HEAD>
<BODY>
<FORM ID=&quot;frmOrder&quot; NAME=&quot;frmOrder&quot; ACTION=&quot;PlaceOrder.asp&quot; METHOD=&quot;Post&quot;>
<BLOCKQUOTE>
<H3>
To generate an order enter in your first name, last name,
the quantity, and select a product to purchase.
</H3>
<HR>
<BR>

First Name:
<BR>
<INPUT TYPE=&quot;text&quot; ID=&quot;txtFN&quot; NAME=&quot;txtFN&quot;>
<P>

Last Name:
<BR>
<INPUT TYPE=&quot;text&quot; ID=&quot;txtLN&quot; NAME=&quot;txtLN&quot;>
<P>

Products:
<BR>
<SELECT ID=&quot;optProducts&quot; NAME=&quot;optProducts&quot;>
<font face=&quot;Arial&quot; size=2>
<p>Microsoft VBScript runtime </font> <font face=&quot;Arial&quot; size=2>error '800a01a8'</font>
<p>
<font face=&quot;Arial&quot; size=2>Object required</font>
<p>
<font face=&quot;Arial&quot; size=2>/TestProject/Orders.asp</font><font face=&quot;Arial&quot; size=2>, line 35</font>


As you can see, it stops at that line of code and doesn't even pretend to complete the page. The line that it is stopping on is &quot;do until rsProducts.eof&quot;, saying Object Required. Still working on trying to use an open connection. My boss has suggested just getting the information and creating the HTML table in VB component, but have to learn that as well since never done it before. Would prefer just having the answer to this as it stands, obviously. :) Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top