Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

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 "'?
0
d34thk
Asked:
d34thk
  • 8
  • 5
  • 4
  • +2
1 Solution
 
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
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 5
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now