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!

Object Require: " ????? 4

Status
Not open for further replies.

PhatH

IS-IT--Management
Mar 30, 2004
88
US
Hello all,

I got a very frustrating ERROR:

Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/includes/subnav/labelsribbons_subnav.asp, line 4

This is my code:

<% If request.querystring("Labels") <> "" Then
sql = "SELECT * FROM tblRibbons"
Set rs = objConn.Execute(sql)
End If
%>
<div id="subnavlist">
<ul>
<li><A href="/products/hardware/lablesribbons/default.asp?Product=3&Labels=0">Labels</A></li>
<li><A href="/products/hardware/lablesribbons/default.asp?Product=3&Labels=1">Ribbons</A></li>
<% If request.querystring("Labels") = "1" then %>
<FORM>
<SELECT NAME="ribbons">
<%
do while not rs.eof
%>
<OPTION VALUE="<% =rs("RibbonID") %>"><% =rs("RibbonName") %></OPTION>
<%
rs.movenext
loop
%>
</SELECT>
</FORM>
<% End if %>
<li><A href="/products/hardware/lablesribbons/default.asp?Product=3&Labels=2">Get A Quote</A></li>
/ul>
</div>
 
That is where I am at. Something is wrong with the connection string. Try running this on a seperate page:

<%
dim objConn

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Driver={SQL Server};" &_
"Server=***;" &_
"Database=****;" &_
"Network=DBMSSOCN;" &_
"Uid=***;" &_
"Pwd=***;"

Response.write objConn.state

%>

This should tell you if the connection is open or closed and if the problem is in the connection string.

 
amorous...

New ERROR:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/includes/subnav/labelsribbons_subnav.asp, line 4

I don't know why but I used the exact code that I used for another page, and until now, that other page is still working fine, which means my database connection is ok. Since I copy and only change the database and rs names. I think the ASP code is not totally bad either.

In short, I think there must be something else other than the DB connection and RS have caused the ERROR.

Thank you all of you for the help.

I guess I'll find another approach to get to where I want to be.

Thank again!!! :)
 
To CassidyHunt,

I tried the 2 lines:
<%
dim objConn

Response.write objConn.state
%>
and the codes are currently located in a self file namely dbconn.asp

tested, and the ERROR is still there.

Thank you anyway!!!
 
This shouldn't be to difficult to solve if you paste the EXACT code the appears at the top of the page where the error is occurring.
That includes include directives.

My guess is that your
a) Not using Option Explicit
b) Not declaring the objConn variable so that it has scope in both the file with the error and the file with the connection code

I don't see your include to include your database connection file. Even if that include is right above the code you originally posted you could be having a scope issue where the variable is only meaningful to that included file (one of the dangers of not using Option Explicit and Dim'ing your variables).


If you get an error after the following changes, then it is not because the changes are in error, but instead it is likely because there are other errors in your code.
Code:
<%
Dim objConn, sql, rs

'original connectionstring pasted here instead of magically included
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Driver={SQL Server};" &_
    "Server=***;" &_
    "Database=****;" &_
    "Network=DBMSSOCN;" &_
    "Uid=***;" &_
    "Pwd=***;"

If request.querystring("Labels") <> "" Then
   sql = "SELECT * FROM tblRibbons"
   Set rs = objConn.Execute(sql)
End If

%>

Withoput seeing what you are including where I cannot guess further what the problem might be. I have a sneaking suspicion that you actually have another page including the one you have pasted above, adding another layer of complexity to this.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
You're right Tawn

I haven't declared Option Explicit, ObjConn, nor Dim'ing my variable lately.

In my every page has <--! include ... --> that link to the page "dbconn.asp" and some other pages as well, which also like you said causing even more complication to my code.

My question to you:

How should I start declaring variables such as Objconn, rs, ... that will be reuse again and again in every different page? I saw people using RS.CLOSE and SET RS=NOTHING that I didn't see in books. Is that how to finish up used variables after every closing page?

I guess I should have learned to do the right way in the beginning instead of cutting short while learning the code. :)

Thank Tawn.
 
UPDATE, UPDATE!!!

I found where the problem that is located in the include page on way top that link to "function.asp" which will then open "dbconn.asp".

It's working now. But I believe that I should start learning to apply what I have learned in all of your help today to make my pages better.

Thank you all!!!
 
RS.Close closes the recordset object (and it's open connection if nothing else is using that connection).
Setting an object to Nothing is a method of cleaning up after yourself. Basically it frees up the refernce so that the system knows that memory location is no longer in use. Eventually the system will figure it out on it's own, basically setting it to nothing is thwe polite method.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top