User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 391,940 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,865 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 1543 | Replies: 4 | Solved
Reply
Join Date: Aug 2007
Posts: 54
Reputation: rrocket is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
rrocket's Avatar
rrocket rrocket is offline Offline
Junior Poster in Training

Help Object required Error

  #1  
Feb 1st, 2008
Anyone have a clue what I am doing wrong here?

I have tried to call this function a bunch of different ways, but here is the latest:

mProfitPercent = GetProfitPercent

Here is the function that I am trying to call:

  1. Function GetProfitPercent
  2. Dim rsRegx
  3. Set rsRegx = Nothing
  4. 'Set rsReg = ActiveConnection
  5. sSQL="SELECT PROFIT_PERCENT FROM t_DIRECTORY WHERE directory_id = '" & Session("UserLocationId") & "'"
  6. set rsRegx = server.CreateObject("adodb.recordset")
  7.  
  8. rsRegx.cursorlocation = aduseclient
  9. rsRegx.cursortype = adkeyset
  10. rsRegx.open sSQL, gobjConnect
  11.  
  12. if not rsRegx.eof then
  13. Session("PPercent") = rsRegx("PROFIT_PERCENT") & ""
  14. else
  15. Session("PPercent") = ".15"
  16. end if
  17.  
  18. rsRegx.Close
  19. Set rsRegx = Nothing
  20. CloseDbConn
  21. End Function

Here is the exact error I am getting:
Microsoft VBScript runtime error '800a01a8'

Object required

It errors on an Execute statement...

Thanks!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 1,054
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Object required Error

  #2  
Feb 4th, 2008
It is telling you that "Session("UserLocationId")" is not an object, it is not set. Check to make sure it is spelled correctly, and if the ID is an integer field in the database, remove the single quotes in the sSQL statement.

Or that gobjConnect does not exist, or rsRegx is not set (which above it is). But where is gobjConnect??
Last edited by SheSaidImaPregy : Feb 4th, 2008 at 9:49 am.
Reply With Quote  
Join Date: Aug 2007
Posts: 54
Reputation: rrocket is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
rrocket's Avatar
rrocket rrocket is offline Offline
Junior Poster in Training

Help Re: Object required Error

  #3  
Feb 4th, 2008
After messing around with it and hardcoding some numbers in and it looks like it is not getting the value out of this:
  1. Session("PPercent") = rsRegx("PROFIT_PERCENT") & ""

If I replace reRegx("PROFIT_PERCENT") with ".12" it works just fine. I cannot figure out why it is not pulling the Profit_Percent value out of the DB. Any ideas?
Reply With Quote  
Join Date: Sep 2007
Posts: 1,054
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Object required Error

  #4  
Feb 4th, 2008
Do you have a correct match, you have records? Do a count of records returned.

remove the last ' & "" ' bit from the end, there is no need for it.

Also, every column in a database is case-sensitive. Make sure that i is "PROFIT_PERCENT" and not "Profit_Percent", you know? Verify the spelling and cases.
Reply With Quote  
Join Date: Aug 2007
Posts: 54
Reputation: rrocket is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
rrocket's Avatar
rrocket rrocket is offline Offline
Junior Poster in Training

Help Re: Object required Error

  #5  
Feb 5th, 2008
Here is what I ended up with... I ended up creating another connection instead of calling another function that should have opened the connection (it works on a few other functions).

  1. Function GetProfitPercent
  2. Dim rsReg
  3. Dim value
  4. 'OpenDbConn - did not work for me this time for whatever reason. This is what called the function that Conn does now.
  5.  
  6. Set rsReg = Nothing
  7. set Conn = Server.CreateObject("ADODB.Connection")
  8. Conn.Open gsConnect
  9. 'Set rsReg = ActiveConnection
  10. sSQL="SELECT PROFIT_PERCENT FROM Table WHERE directory_id = '" & Session("UserLocationId") & "'"
  11. set rsReg = server.CreateObject("adodb.recordset")
  12.  
  13. rsReg.cursorlocation = aduseclient
  14. rsReg.cursortype = adkeyset
  15. rsReg.open sSQL, Conn
  16.  
  17. if not rsReg.eof then
  18. Session("PPercent") = rsReg("PROFIT_PERCENT") & ""
  19. value = Session("PPercent")
  20. else
  21. Session("PPercent") = ".15"
  22. value = Session("PPercent")
  23. end if
  24.  
  25. rsReg.Close
  26. Set rsReg = Nothing
  27.  
  28. GetProfitPercent = value
  29. End Function

Thanks for the help.
Last edited by rrocket : Feb 5th, 2008 at 4:34 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 8:44 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC