Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 1st, 2006, 02:22 AM
Authorized User
 
Join Date: Sep 2005
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Command Object - commandType error

I'm using command object and everytime I declare it like so:

objCommand.CommandType = adCmdText

OR

objCommand.CommandType = adCmdTable

I get an error. but without it, it works fine. how come??

 
Old February 1st, 2006, 07:25 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi europhreak,

What type of command are you executing - sql query / stored proc / table opening?

Have you got a reference to the ADO constants in your page?

Cheers,

Chris

 
Old February 1st, 2006, 09:49 AM
Authorized User
 
Join Date: Sep 2005
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i'm using access database with one table. in the book beggining asp 3.0 they're only specifying constants with a CONNECTION object but not with Command object.

 
Old February 1st, 2006, 10:54 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

adCmdText and adCmdTable are ADO constants, if you don't reference or declare them in your page you will get errors.

HTH,

Chris

 
Old February 1st, 2006, 01:01 PM
Authorized User
 
Join Date: Sep 2005
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

see the problem is that when i DO NOT specify them it works fine, when i DO specify i get an error.


 
Old February 1st, 2006, 01:09 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

That is beacuse if you do not specify a CommandType ADO works out which type of CommandType to use, this will take longer than specifying the correct CommandType to start with.

If you pass it a CommandType for example adCmdText without defining the ADO constants first you will be passing an empty variant to the property causing an error.

 
Old February 1st, 2006, 06:48 PM
Authorized User
 
Join Date: Sep 2005
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok, got it working. simply added this on top of the page:




 
Old February 2nd, 2006, 04:55 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Excellent, so all you needed to do was add the constants after all :D





Similar Threads
Thread Thread Starter Forum Replies Last Post
Command text was not set for the command object Sheraz Khan Classic ASP Databases 2 May 29th, 2007 12:57 AM
Chap 5 - CommandType.Text vs. TableDirect RBrown BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 August 3rd, 2006 06:24 AM
Command text was not set for the command object. deepa12 BOOK: Beginning ASP 3.0 5 November 2nd, 2004 05:37 PM
Help! 'Command object error' sisi Classic ASP Databases 4 May 25th, 2004 06:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.