?
Solved

Stupid error, but i can't see it.

Posted on 2003-02-26
19
Medium Priority
?
183 Views
Last Modified: 2008-03-17
Technical Information (for support personnel)

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/combat.asp, line 134

theres the error i get, in this patch of code...


dim defcalc
iSQL = "SELECT * FROM items WHERE name = '" & playerarmour & "'"
irs.Open iSQL,iconn,3,3
defcalc = irs.Fields("def")
irs.Close

the error is on the irs.open line. but i can't see the problem. obviously, playerarmour has already been defined, as has irs, and iSQL has been declared. why is it saying i need the 'object "'?
0
Comment
Question by:d34thk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 4
  • +2
19 Comments
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 8024534
what's iconn then?

this should be an open adodb connection object.
0
 
LVL 28

Accepted Solution

by:
sybe earned 340 total points
ID: 8024550
you are probably mising this:

Set irs = Server.CreateObject("ADODB.RecordSet")
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 8024578
And once you've got all your objects declared and opened, you're going to need to alter your SQL slightly:

iSQL = "SELECT * FROM items WHERE [name] = '" & playerarmour & "'"

I think name is a predefined word in SQL?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:d34thk
ID: 8024595
ive got all of it declared as i already said.

name is the label of a field i have in my database.
0
 
LVL 28

Expert Comment

by:sybe
ID: 8024615
Yeah, AlfaNoMore is probably right, "name" might well be a protected word, and you need to write [name] when you refer to a table called "name".
0
 

Author Comment

by:d34thk
ID: 8024624
ive got all of it declared as i already said.

name is the label of a field i have in my database.
0
 

Author Comment

by:d34thk
ID: 8024627
dun think so, cuz so far it works in all my other queries with name in it.
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 8024629
declared is not the same as open. This is what it should be like:

Dim iconn
dim irs
dim iSQL
dim defcalc

iSQL = "SELECT * FROM items WHERE name = '" & playerarmour & "'"

Set iconn = server.createobject("ADODB.Connection")
iconn.Open "?dnsstring?"

Set irs = Server.CreateObject("ADODB.Recordset")

irs.Open iSQL,iconn,3,3

'you may need some error checking in here, in case the Recordset is empty?

If Not irs.EOF Then _
     defcalc = irs.Fields("def")

irs.Close

set irs = Nothing
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 8024646
You're also going to need some SQL friendly string stuff going on with playerarmour. If it includes an apostrophe, then this'll screw the SQL up:

playerarmour = "someone's text"

iSQL = "SELECT * FROM items WHERE name = '" & funcRepQuotes(playerarmour) & "';"

iSQL will be equal to:
SELECT * FROM items WHERE [name] = 'someone''s text';



Function funcRepQuotes(sText)
   If IsNull(sText) Then Exit Function
   funcRepQuotes = Replace(sText, "'", "''")
End Function
0
 
LVL 4

Expert Comment

by:Wakie
ID: 8024856
Hi d34thk, try this:

dim defcalc
iSQL = "SELECT * FROM items WHERE name = '" & playerarmour & "'"
Set irs = iconn.Execute(iSQL)
If irs.EOF Then
   Response.Write "No records."
   Response.End
Else
   defcalc = irs("def")
End If
irs.Close

Regards,
Wakie.
0
 

Author Comment

by:d34thk
ID: 8024859
ok, i'll explain mroe clearly

wht you're seeing is a piece of my code. i already have all the recordsets and connections opena dn ready to use. the playerarmour string does not have any apostrophes in it either.
0
 

Author Comment

by:d34thk
ID: 8024873
that didnt work either, same error as before,

object required: "
0
 
LVL 28

Expert Comment

by:sybe
ID: 8024922
obviously we are all trying to find where the error is, and do suggestions.

The part of your code that you show, can or can not be the source of the error. We're just guessing. And I think that the guesses that have been made make sense. At least I recognize all as possible causes for the error.


so very specific:

================
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/combat.asp, line 134
==============

question: which line of your code is line 134 ??

0
 
LVL 15

Expert Comment

by:gladxml
ID: 8024929
d34thk,

Have you included adovbs.inc in your file...

Just checking...
0
 

Author Comment

by:d34thk
ID: 8024933
that didnt work either, same error as before,

object required: "
0
 

Author Comment

by:d34thk
ID: 8024941
oops, double post. um, line 134 is the
irs.open iSQL,iconn,3,3 line, as i said earlier
0
 
LVL 28

Expert Comment

by:sybe
ID: 8024946
The error is a "VBScript Runtime" error, and it says "object required".

I would say that you use a non-object as an object:
- not using "Set" where you should
- using a method/property from a non-object.

0
 
LVL 28

Expert Comment

by:sybe
ID: 8024974
I would say that irs is not an object, check it:

Response.write TypeName(irs)
irs.open iSQL,iconn,3,3
0
 

Author Comment

by:d34thk
ID: 8024992
LOL, oops.

i'd like to say that i am in incomptetant fool, and i didn't really listen to anything said. i got the problem, realising that i'd opened connections for 3 different databases, but not this one. :/ *smacks self in head*

credit goes to sybe for pointing it out first.

thanx a heap all, i would never had realised hwo stupid i am if not for this :P
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question