VB Script Error

I get the following error which I am not  able to figure out. Can any body tell me why this error message. I am working on personal web server.
Error Message
Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'open'

/dblinking.asp, line 16

My code is posted below.

<% @ Language=VBScript %>

<% Response.Buffer = true %>  

<!--#include file="adovbs.asp"-->


dim Cmd1,Cmd2
dim mydb1,mydb2
set Cmd1 = Server.CreateObject("ADODB.Command")
 mydb1 = "DSN=listtables;uid=scott; pwd =tiger"
 Cmd1.open mydb1
 set Cmd2 = Server.CreateObject("ADODB.Command")
 mydb2 = "DSN=classifieddata;uid=scott; pwd =tiger"
 Cmd2.open mydb2
'oCmd1.CommandType = adCmdText
 'oCmd1.Prepared = true
dim my_sqlquery1,sessionitem,sessionquantity
sessionitem = session("item")
sessionquantity = session("quantityintons")
my_sqlquery1 = "select sessionquantity from listing where item = sessionitem"
'oCmd1.CommandText = "my_sqlquery1"
 set Rs1 = server.CreateObject("ADODB.Recordset")
 Rs1.open my_sqlquery1, oCmd1,0
 'if  not oRs1.EOF then       
 'end if
 'on db2
' oCmd2.CommandType = adCmdText
dim my_sqlquery2
my_sqlquery2 = "select sum(quantityintons) from getdatafrombids where item = sessionitem"
'oCmd2.Prepared = true
 'oCmd2.CommandText = "my_sqlquery2"
 set Rs2 = server.CreateObject("ADODB.Recordset")
 Rs2.open my_sqlquery2, Cmd2,0
 'if  not oRs1.EOF then       
'end if

 dim var1, var2
 var1 = oRs1.fields.Item("quantityintons").value
 var2 = oRs2.fields.Item("quantityintons").value  
if var1 = var2 then

my_sqlquery1 = " update listing set quantityintons = var1-var2 where item = sessionitem"
elseif var1>var2 then  

my_sqlquery1 = " update listing set quantityintons = var1-var2 where item = sessionitem"

my_sqlquery1 = "update listing set quantityintons = 0 where item = sessionitem"
end if

set oRs1 = nothing
set oRs2 = nothing
set oCmd1 = nothing
set oCmd2 = nothing
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.

The ADODB Command object does not support the "open" method.  It does, however, support "Execute".  I think you need to change your code above to:

Set Cmd1 = server.createobject("ADODB.Connection"), etc.

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
Actually, I was a bit hasty (hit the wrong button).

You will need a connection object AND a command object.  You use the command object later in the code, but you still need a separate connection object.

ramani081399Author Commented:

 Yes I realized as soon as I posted the query. Yes it works ok now. Thanks for your help.
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

From novice to tech pro — start learning today.