×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

ERROR 424 Object Required

ERROR 424 Object Required

ERROR 424 Object Required

(OP)
Hello guys, this migrating to new server thing is really starting to annoy me!! OK, the situation. I have the following piece of code in a include file.

On Error Resume Next

function OpenDB
dim con
On Error Resume Next
err.clear
set con = session("con")
If Not (IsObject(con)) Then
response.write "opening new connection"
Set con = Server.CreateObject("ADODB.Connection")
set session("con") = con

if err.number <> 0 then
response.write err.number
response.write err.description
response.write "before open con"
end if

strDSN = Session("strDSN")
con.Open "DSN=" & strDSN
response.write "opened new session successfully"
Else
response.write "did not open new session"
'do nadda!
End If
        
If err.number <> 0 Then
err_count = 1
Response.write("Database Errors Occured" & "<P>")
Response.write("Error #" & err.number & "<P>")
Response.write("Error desc." & err.description & "<P>")
End If

openDB = con
End function

I keep getting the following error (first time I run the code the second time it thinks there is a connection so pass through this function ok)

ERROR 424
OBJECT REQUIRED

Can anyone tell me where I am going wrong?

RE: ERROR 424 Object Required

Does it tell you whic line is throwing the error?

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots.  So far, the Universe is winning. - Rick Cook (No, I'm not Rick)


RE: ERROR 424 Object Required

(OP)
It doesn't as such - but the first error checking bit does produce the error, so I think it is something to do with the

Set con = Server.CreateObject("ADODB.Connection")
set session("con") = con

since the last post I commented out the
set con = session("con")
and it went through the code alright, until i called openDB and I got the same error.

RE: ERROR 424 Object Required

The error is because you are using SET word. Which in this case it expects to have an valid object on the right side but since the first time Session("con") is empty that is the error.

You could use something like this instead
If session("con")="" Then
'open e new connection.
 set session("con")= con
end if
'if it's alreadey opened then start using it
set con=session("con")

________
George, M

RE: ERROR 424 Object Required

(OP)
Could I put my code to set up the connection in the following place?


If session("con")="" Then
'open e new connection.
<<code>>
 set session("con")= con
end if
'if it's alreadey opened then start using it
set con=session("con")

RE: ERROR 424 Object Required

(OP)
another question, when I am making a call to the function above, do I call it like this?

set con = OpenDB()

or is this syntaxly incorrect?

RE: ERROR 424 Object Required

Yes you place the code exactly there.

set con = OpenDB() will work if you will return an object

function OpenDB
 set newConn=Server.CreateObject("ADODB.Connection")
 'open your new connection
 OpenDB=newConn
end function
...

If session("con")="" Then
'open e new connection.
 set session("con")= OpenDB
end if
'if it's alreadey opened then start using it
set con=session("con")

________
George, M

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close