Stupid error, but i can't see it.

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 "'?
d34thkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlfaNoMoreCommented:
what's iconn then?

this should be an open adodb connection object.
0
sybeCommented:
you are probably mising this:

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AlfaNoMoreCommented:
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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

d34thkAuthor Commented:
ive got all of it declared as i already said.

name is the label of a field i have in my database.
0
sybeCommented:
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
d34thkAuthor Commented:
ive got all of it declared as i already said.

name is the label of a field i have in my database.
0
d34thkAuthor Commented:
dun think so, cuz so far it works in all my other queries with name in it.
0
AlfaNoMoreCommented:
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
AlfaNoMoreCommented:
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
WakieCommented:
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
d34thkAuthor Commented:
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
d34thkAuthor Commented:
that didnt work either, same error as before,

object required: "
0
sybeCommented:
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
gladxmlCommented:
d34thk,

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

Just checking...
0
d34thkAuthor Commented:
that didnt work either, same error as before,

object required: "
0
d34thkAuthor Commented:
oops, double post. um, line 134 is the
irs.open iSQL,iconn,3,3 line, as i said earlier
0
sybeCommented:
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
sybeCommented:
I would say that irs is not an object, check it:

Response.write TypeName(irs)
irs.open iSQL,iconn,3,3
0
d34thkAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.