[thelist] help: Object required

Ken Schaefer Ken at adOpenStatic.com
Wed May 25 19:58:47 CDT 2005


You really should use a debugger and step through your code.

On line 8 you open a connection object called oConn
On line 9 you create another connection object called connTemp
On line 10 you attempt to do an implicit let. I suspect this is where your
issue is, but may not be BUT this is not the way you should be doing things.

Your SQL statement is also invalid, you have no table or query name there as
your source.

Try doing the following:
a) delete the existing subroutine
b) replace the subroutine with the following:

<%
Function OpenConnection(strDBConnString)

	Dim oConn

	Set oConn = Server.CreateObject("ADODB.Connection")
	oConn.Open strDBConnString

	Set OpenConnection = oConn

End Function
%>

Now, in the main body of your code do the following:

<%
' Put /all/ your Dim statements at the top of your code, not inline
If len(iDocId)>0 then 'doc id has a value

	Set connTemp = OpenConnection(Application("ConnString"))
	sDocQuery = _
		"SELECT doc_checkedout, doc_title, doc_callno " & _
		"FROM <YOUR TABLE NAME HERE> " & _
		"WHERE doc_seq = " & iDocID

	Set objRS = connTemp.Execute(sDocQuery)

End If
%>

And lastly, create an application variable (initialised in
Application_OnStart() in your global.asa) that holds your DB connection
string(s)

Sub Application_OnStart()
	Application("ConnString") = "Provider...."
End Sub

Cheers
Ken

--
www.adOpenStatic.com/cs/blogs/ken/ 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: thelist-bounces at lists.evolt.org [mailto:thelist-
: bounces at lists.evolt.org] On Behalf Of Dena
: Subject: [thelist] help: Object required
: 
: Hey,
: 
: Why do I get "object required" error when I call this subroutine?
: I've looked through microsoft info and googled the problem, and it
: should work.
: 
: 1 sub subOpenDBConn()
: 2    dim oConn, Path, dbConn, conntemp
: 3    Path = Server.MapPath ("/datastore/library.mdb")
: 4    Set oConn = Server.CreateObject("ADODB.Connection")
: 5    dbConn = "Provider=Microsoft.Jet.OLEDB.4.0;" &_
: 6         "Data Source = "&Path&";" &_
: 7         "Persist Security Info = FALSE"
: 8    oConn.Open dbConn
: 9    set conntemp=server.createobject("adodb.connection")
:10     conntemp.open oConn
:11 end sub
: 
: here's the page that calls the sub
: 
: <% Option Explicit %>
: <% response.buffer=TRUE %>
: <%
: 
: if len(iDocId)>0 then 'doc id has a value
:   call subOpenDBConn()
:   dim conntemp
:   dim sDocQuery
:   sDocQuery="SELECT doc_checkedout, doc_title, doc_callno where doc_seq =
: "
: & iDocId & ";"
:   dim rsDoc: set rsDoc=conntemp.execute(sDocQuery) 'this lines gives the
: error
: end if %>
: 
: the error points to the last line above
: Microsoft VBScript runtime (0x800A01A8)
: Object required: ''
: 
: 
: 
: --
: 
: * * Please support the community that supports you.  * *
: http://evolt.org/help_support_evolt/
: 
: For unsubscribe and other options, including the Tip Harvester
: and archives of thelist go to: http://lists.evolt.org
: Workers of the Web, evolt !


More information about the thelist mailing list