Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command_text_was_not_set_for_the_command_object 1

Status
Not open for further replies.

perryair

IS-IT--Management
Apr 7, 2005
91
IL
Hi...
When I run the following code I receive the above error on line 9 (DB.Open).

Any Idea?


<%

Dim DB, RS
Set DB = Server.CreateObject("ADODB.Recordset")


DB.activeconnection= ("DRIVER={SQL Server};SERVER=SQL2000;DATABASE=database1;UID=userid;PWD=password")

DB.Open

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


RS.Open "SELECT * FROM sale WHERE ItemID= " & Request.QueryString("ItemID"), DB, adOpenKeySet,adLockOptimistic,adCmdText

If RS.BOF and RS.EOF Then

Response.Write "<p align='center'>Sorry, no files!</p>"

Else


Response.Write RS("ItemName")

End If

RS.Close

Set RS = Nothing

DB.Close

Set DB = Nothing



%>
 

Change this:
Set DB = Server.CreateObject("ADODB.Recordset")
to:
Set DB = Server.CreateObject("ADODB.Connection")

Change this:
DB.activeconnection= ("DRIVER={SQL Server};SERVER=SQL2000;DATABASE=database1;UID=userid;PWD=password")
to:
DB.ConnectionString = "DRIVER={SQL Server};SERVER=SQL2000;DATABASE=database1;UID=userid;PWD=password"



A smile is worth a thousand kind words. So smile, it's easy! :)
 
Thanks damber....
However, now it says:
14|800a01c2|Wrong_number_of_arguments_or_invalid_property_assignment:_'Open'

I assume this refer to 'RS.Open' ?
 

Do you have the adovbs.inc file included in your ASP file ? or the following type libaray in your global.asa:

Code:
<!--METADATA 
	TYPE="typelib" 
    FILE="C:\Program Files\Common Files\System\ADO\msado20.tlb"
-->

If you don't have either then the script will not know what "adOpenKeySet,adLockOptimistic,adCmdText" relates to as these are constants set by either of the above options.

including adovbs.inc in the ASP file is easy but less efficient than the typelib option.



A smile is worth a thousand kind words. So smile, it's easy! :)
 
THANKS for your help !!..... you've got a star!!!
 

You're welcome
Thanks for the star :)

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top