...

View Full Version : Microsoft VBScript runtime (0x800A01A8) Object required: ''



bex1984
06-15-2007, 12:56 PM
I've been getting this annoying error on line 360, which is the connection and recordset close script (shown below)

<%
set connect1=Nothing
Recset1.close
set Recset1=nothing

set itemconn=Nothing
itemRecset.close
set itemRecset=nothing

set connect2=Nothing
Recset2.close
set Recset2=Nothing

set itemconn2=Nothing
itemRecset2.close <----------- line 360
set itemRecset2=nothing
%>

Due to this "object required" error it obviously isn't this line which is causing probs.

Here is what I am trying to do.........

I already have a working script (pasted below) which pulls all info from the reputation table, but I also want to drag only the item_title from the auction_items table.


' <------- All buying reputations are retrieved from the database ------->

Dim connect1
Dim Recset1
Dim itemconn
Dim itemRecset

' ADO conection on the server...
set connect1=server.CreateObject("adodb.connection")

' OLEDB open database script
connect1.Provider="Microsoft.JET.OLEDB.4.0"
connect1.Open Server.Mappath("database/sibis.mdb")

' recordset object to store results of an SQL query...
set Recset1=server.CreateObject("adodb.recordset")

Recset1.Open "Select * FROM reputation WHERE user_id = " & session("user_id") & " AND reputation_type IN ('buy')",connect1, adOpenkeyset, AdLockOptimistic

Response.Write "<font color='red'>Recordcount for selling reputation is: " & Recset1.RecordCount & " EOF? :" & Recset1.EOF & " Session ID of user is : " & session("user_id") & "</font> &nbsp;&nbsp;"



Here is the problem script........


If Recset1.EOF Then

Response.Write("You do not have a buying reputation yet")

Else

' ADO conection on the server...
set itemconn=server.CreateObject("adodb.connection")

' OLEDB open database script
itemconn.Provider="Microsoft.JET.OLEDB.4.0"
itemconn.Open Server.Mappath("database/sibis.mdb")

' recordset object to store results of an SQL query...
set itemRecset=server.CreateObject("adodb.recordset")

itemRecset.Open "SELECT item_title FROM auction_items WHERE user_id =" & session("user_id"),itemconn, adOpenkeyset, AdLockOptimistic

End If



Any help would be greatly appreciated! :)

Daemonspyre
06-15-2007, 01:04 PM
Since (in your script above) you never Dim or server.CreateObject itemRecset2, and therefore you never open it, how can ASP close the item?

You are getting the error because ASP requires that object to be defined and opened before it can close it.

Try commenting out that line, and subsequently the line below it.

HTH!

bex1984
06-15-2007, 01:29 PM
I have already defined those other variables as there is another script like the one pasted above.
One for buying reputation and one for selling.
Here is the FULL script to save confusion, just wanted to cut down the length of the post!

<%@ Language=VBScript%>
<%
option explicit ' This declares all global variables utilised in the script
' This ensures a secure login
IF session("loggedin")=FALSE Then
Response.Redirect("login.asp")
End IF

' <------- All buying reputations are retrieved from the database ------->

Dim connect1
Dim Recset1
Dim itemconn
Dim itemRecset

'ADO conection on the server...
set connect1=server.CreateObject("adodb.connection")

' OLEDB open database script
connect1.Provider="Microsoft.JET.OLEDB.4.0"
connect1.Open Server.Mappath("database/sibis.mdb")

' recordset object to store results of an SQL query...
set Recset1=server.CreateObject("adodb.recordset")

Recset1.Open "Select * FROM reputation WHERE user_id = " & session("user_id") & " AND reputation_type IN ('buy')",connect1, adOpenkeyset, AdLockOptimistic

Response.Write "<font color='red'>Recordcount for selling reputation is: " & Recset1.RecordCount & " EOF? :" & Recset1.EOF & " Session ID of user is : " & session("user_id") & "</font> &nbsp;&nbsp;"

' <------- All selling reputations are retrieved from the database ------->

Dim connect2
Dim Recset2
Dim itemconn2
Dim itemRecset2

' ADO conection on the server...
set connect2=server.CreateObject("adodb.connection")

' OLEDB open database script
connect2.Provider="Microsoft.JET.OLEDB.4.0"
connect2.Open Server.Mappath("database/sibis.mdb")

' recordset object to store results of an SQL query...
set Recset2=server.CreateObject("adodb.recordset")

Recset2.Open "SELECT * FROM reputation WHERE user_id =" & session("user_id") & " AND reputation_type IN ('sell')",connect2, adOpenkeyset, AdLockOptimistic

Response.Write "<font color='red'>Recordcount for selling reputation is: " & Recset2.RecordCount & " EOF? :" & Recset2.EOF & " Session ID of user is : " & session("user_id") & "</font> &nbsp;&nbsp;"

If Recset1.EOF Then

Response.Write("You do not have a buying reputation yet")

Else

' ADO conection on the server...
set itemconn=server.CreateObject("adodb.connection")

' OLEDB open database script
itemconn.Provider="Microsoft.JET.OLEDB.4.0"
itemconn.Open Server.Mappath("database/sibis.mdb")

' recordset object to store results of an SQL query...
set itemRecset=server.CreateObject("adodb.recordset")

itemRecset.Open "SELECT item_title FROM auction_items WHERE user_id =" & session("user_id"),itemconn, adOpenkeyset, AdLockOptimistic

End If

If Recset2.EOF Then

Response.Write("You do not have a selling reputation yet")

Else

' ADO conection on the server...
set itemconn2=server.CreateObject("adodb.connection")

' OLEDB open database script
itemconn2.Provider="Microsoft.JET.OLEDB.4.0"
itemconn2.Open Server.Mappath("database/sibis.mdb")

' recordset object to store results of an SQL query...
set itemRecset2=server.CreateObject("adodb.recordset")

itemRecset2.Open "SELECT item_title FROM auction_items WHERE user_id =" & session("user_id"),itemconn2, adOpenkeyset, AdLockOptimistic

End If

%>


This is the WHOLE chunk of ASP before the HTML page starts

Daemonspyre
06-15-2007, 02:27 PM
The only thing that I can think of as to why you are getting this error is here:



If Recset2.EOF Then

Response.Write("You do not have a selling reputation yet")

Else

' ADO conection on the server...
set itemconn2=server.CreateObject("adodb.connection")

' OLEDB open database script
itemconn2.Provider="Microsoft.JET.OLEDB.4.0"
itemconn2.Open Server.Mappath("database/sibis.mdb")

' recordset object to store results of an SQL query...
set itemRecset2=server.CreateObject("adodb.recordset")

itemRecset2.Open "SELECT item_title FROM auction_items WHERE user_id =" & session("user_id"),itemconn2, adOpenkeyset, AdLockOptimistic

End If


Basically this says: If you have some rep, great show it, if you don't, show a message.

Since you do not open your itemRecset2 UNLESS someone has some selling reputation, you cannot close it.

So, you are running into this error if a user doesn't have any selling Rep.

How do you fix it?



<%
set connect1=Nothing
Recset1.close
set Recset1=nothing

set itemconn=Nothing
itemRecset.close
set itemRecset=nothing

set connect2=Nothing
Recset2.close
set Recset2=Nothing

' **** MODIFICATION
IF itemconn2.State = 1 THEN ' if the Selling Rep is not EOF and connection is made/open

itemRecset2.close
itemconn2.close

END IF

set itemRecset2=nothing
set itemconn2=nothing

%>

bex1984
06-15-2007, 02:41 PM
I have now amended the script to what you suggested but the same error is appearing, now at line 363.

<%
set connect1=Nothing
Recset1.close
set Recset1=nothing

IF itemconn.State = 1 THEN ' if the Selling Rep is not EOF and connection is made/open

itemRecset.close
itemconn.close

END IF

set itemconn=Nothing
set itemRecset=nothing

set connect2=Nothing
Recset2.close
set Recset2=Nothing

IF itemconn2.State = 1 THEN ' if the Selling Rep is not EOF and connection is made/open <---------- Line 363

itemRecset2.close
itemconn2.close

END IF

set itemRecset2=nothing
set itemconn2=nothing

%>

Daemonspyre
06-15-2007, 03:02 PM
Ah... Same issue.

If Recset2 IS EOF, then not even your itemconn2 gets opened... Sorry I missed that before.

Without re-writing some of your page, this may get difficult. But, I always was a glutton for punishment. Let's give it a go, shall we?

Try:



<%
set connect1=Nothing
Recset1.close
set Recset1=nothing

IF IsObject(itemconn) = TRUE THEN 'check to make sure it's an object
IF itemconn.State = 1 THEN 'check to see if it connection is made/open
itemRecset.close
itemconn.close
END IF
END IF

set itemconn=Nothing
set itemRecset=nothing

set connect2=Nothing
Recset2.close
set Recset2=Nothing

IF IsObject(itemconn2) = TRUE THEN 'check to make sure it's an object
IF itemconn2.State = 1 THEN 'check to see if it connection is made/open
itemRecset2.close
itemconn2.close
END IF
END IF

set itemRecset2=nothing
set itemconn2=nothing

%>


If that doesn't work, then you may need to post a little more of your HTML page so that I can see where you have your itemRecset2 items displayed.

We also may need to switch this to array objects versus database recordsets.

bex1984
06-15-2007, 03:13 PM
:eek: IT WORKS!!!!

Thank you very much for all your help, we were only taught 8 weeks of ASP and most of it was pretty basic.

Got quite a few scripts with similar errors so I'll try using this technique again and if all else fails I might have to post a new thread!

Once again, many thanks for all your help..... deadline looms!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum