Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 17th, 2004, 03:02 PM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBScript runtime (0x800A01A8) Object required

Evening ( morning. ahh shucks... Hi.

Learning ASP but been VB programmer and I think some habits die hard...
can someone please explain the error of my ways..

I want to have a connection opened in a function or subroutine as follows
it's in a seperate include file and yes included....


    Function SetConn(db)
    Set Conn = Server.CreateObject("ADODB.Connection")
    MdbFilePath = "D:\Inetpub\wwwroot\Database\" & DB & ".mdb"
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MdbFilePath & ";User Id=admin;Password="
    SetConn = Conn
    end Function

db is passed to it by calling it such as
Set MyConn = SetConn("Helpdesk")
after 'set'ing the RS and msql for the sql statement

RS.Open msql, MyConn works fine......

however, you can't use MyConn.Close as the object doesn't exist...

I have tried elsewhere and suggestion was put it in a sub in an inc file ( which the function already is )

The reason for having as a function is so I have one point of code to change, and it's used frequently in the code.

Does anyone have experience with this or any suggestions.....
I just want to be able to close MyConn.

Sean






Reply With Quote
  #2 (permalink)  
Old March 17th, 2004, 04:51 PM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have come up with a kind of solution, but not very glamourous in fact quite ugly....

after using the record set I call a CloseConn Function,
Open the connection to the DB again, and close it.

Not 100% sure, but it seems to be helping clear the lines..

would really like a proper answer though :)


Reply With Quote
  #3 (permalink)  
Old March 17th, 2004, 04:54 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,409
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Just like the variable inside the function, you need to set the function return:

Function SetConn(db)
    Set Conn = Server.CreateObject("ADODB.Connection")
    ...
    Set SetConn = Conn
end Function
Reply With Quote
  #4 (permalink)  
Old March 17th, 2004, 04:59 PM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it already is

    Function SetConn(db)
    Set Conn = Server.CreateObject("ADODB.Connection")
    MdbFilePath = "D:\Inetpub\wwwroot\Database\" & DB & ".mdb"
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MdbFilePath & ";User Id=admin;Password="
    SetConn = Conn
    end Function


Reply With Quote
  #5 (permalink)  
Old March 17th, 2004, 05:08 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,409
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Function SetConn(db)
    Set Conn = Server.CreateObject("ADODB.Connection")
    ...
    Set SetConn = Conn
end Function
Reply With Quote
  #6 (permalink)  
Old March 18th, 2004, 03:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Peter is correct, you're missing the Set statement. But why do you bother with the intermediate Conn variable? Why not just:
Code:
Function SetConn(db) 
    Set SetConn = Server.CreateObject("ADODB.Connection")
    MdbFilePath = "D:\Inetpub\wwwroot\Database\" & db & ".mdb"
    SetConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MdbFilePath & ";User Id=admin;Password="
End Function
Reply With Quote
  #7 (permalink)  
Old March 18th, 2004, 03:13 PM
Authorized User
 
Join Date: Mar 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks,
between the two of you and a little more vigilant checking, have resolved it.

Sometimes there was also no SET before the MyConn = SetConn("Helpdesk")

So I have revised the whole lot.
Two connections get opened and used throughout.
    Function SetConn
    Set SetConn = Server.CreateObject("ADODB.Connection")
    MdbFilePath = "D:\Inetpub\wwwroot\Database\Helpdesk.mdb"
    SetConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MdbFilePath & ";User Id=admin;Password="
    End Function

    Function SetConn1
    Set SetConn1 = Server.CreateObject("ADODB.Connection")
    MdbFilePath = "D:\Inetpub\wwwroot\Database\Users.mdb"
    SetConn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MdbFilePath & ";User Id=admin;Password="
    End Function

used as per PGTIPS suggestion thanks...

then just need to use the relevant SetConn each time I call it
at least I can now close the damn things :)


Thanks



Reply With Quote
  #8 (permalink)  
Old February 20th, 2007, 11:55 PM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello ppl, ive been looking at the same code for an hour or two and instead of deleting everything, i thought id ask for some help! :s

im getting the same prob with the object:
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required

ive got:
Dim DBConn5, rs5
Set DBConn5=server.CreateObject("ADODB.Connection")
DBConn5.Provider="Microsoft.Jet.OLEDB.4.0"
DBConn5.Open "C:\Inetpub\wwwroot\database\db.mdb"
set rs5=Server.CreateObject("ADODB.Recordset")
rs5.Open "SELECT * FROM Users;", DBConn5

do while not rs5.EOF
if (StrCOMP(rs5("username"), adminnew, vbTextCompare)=0) then
organisation=rs5("organisation")
rs5.Close
Set rs5 = Nothing
DBConn5.Close
Set DBConn5 = Nothing
else
rs5.MoveNext
End if
Loop

I get the error on the do while not rs5.EOF. The thing is i have 4 other connections that work in exactly the same way.
Any help is welcome!!!!
thanx

Reply With Quote
  #9 (permalink)  
Old February 21st, 2007, 12:03 AM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

sorry for the fuss, its 5 am and brain is prolly not working...found the problem.......
closing the connection before eof finishes :s

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
VBScript runtime SATYABBSR Pro VB.NET 2002/2003 1 January 10th, 2007 10:13 AM
LOOP - VBScript runtime (0x800A01A8) error Ov1 Classic ASP Databases 5 July 31st, 2006 10:18 AM
create a Line object ,Box object in CR at Runtime? thanhnt Pro VB 6 1 May 16th, 2005 06:51 AM
Microsoft VBScript runtime error '800a01a8' object stevesole Access ASP 9 June 7th, 2004 08:13 PM
runtime error '800a01a8' Object Required: 'Session footohi Classic ASP Basics 1 July 17th, 2003 06:32 PM



All times are GMT -4. The time now is 04:40 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.