Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 21st, 2004, 08:34 AM
Registered User
 
Join Date: May 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help! 'Command object error'

Hi,
I get the following error when i insert data from my asp page:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E0C)
Command text was not set for the command object.

However, the data is saved to my database. Please find attached my code:
Code:
<% LANGUAGE = VBScript%>



<%
'Declare variables

dim TITLE
dim SNAME
dim FNAME
dim MNAME
dim ************
dim MSTATUS
dim BIRTHD
dim SORIGIN
dim NATION
dim ADDC1
dim ADDC2
dim TELNO
dim EMAIL
dim INSNAME1
dim QUAL1
dim INSDISC1
dim GRADE1
dim INSYRAD1
dim INSYRGR1
dim INSNAME2
dim QUAL2
dim INSDISC2
dim GRADE2
dim INSYRAD2
dim INSYRGR2
dim INSNAME3
dim PROBODY1
dim PROCERT1
dim PROYR1
dim PROBODY2
dim PROCERT2
dim PROYR2
dim E2
dim P1
dim P2
dim dbconn
dim sqlInsert1
dim sqlInsert11
dim sqlInsert111
dim sqlInsertConn



' Get the data from the Form and store in local variables.

TITLE=Request.Form.item("TITLE")
SNAME=Request.Form.item("SNAME")
FNAME=Request.Form.item("FNAME")
MNAME=Request.Form.item("MNAME")
************=Request.Form.item("************")
MSTATUS=Request.Form.item("MSTATUS")
BIRTHD=Request.Form.item("BIRTHD")
SORIGIN=Request.Form.item("SORIGIN")
NATION=Request.Form.item("NATION")
ADDC1=Request.Form.item("ADDC1")
ADDC2=Request.Form.item("ADDC2")
TELNO=Request.Form.item("TELNO")
EMAIL=Request.Form.item("EMAIL")
INSNAME1=Request.Form.item("INSNAME1")
QUAL1=Request.Form.item("QUAL1")
INSDISC1=Request.Form.item("INSDISC1")
GRADE1=Request.Form.item("GRADE1")
INSYRAD1=Request.Form.item("INSYRAD1")
INSYRGR1=Request.Form.item("INSYRGR1")
INSNAME2=Request.Form.item("INSNAME2")
QUAL2=Request.Form.item("QUAL2")
INSDISC2=Request.Form.item("INSDISC2")
GRADE2=Request.Form.item("GRADE2")
INSYRAD2=Request.Form.item("INSYRAD2")
INSYRGR2=Request.Form.item("INSYRGR2")
INSNAME3=Request.Form.item("INSNAME3")
PROBODY1=Request.Form.item("PROBODY1")
PROCERT1=Request.Form.item("PROCERT1")
PROYR1=Request.Form.item("PROYR1")
PROBODY2=Request.Form.item("PROBODY2")
PROCERT2=Request.Form.item("PROCERT2")
PROYR2=Request.Form.item("PROYR2")
E2=Request.Form.item("E2")
P1=Request.Form.item("P1")
P2=Request.Form.item("P2")

sqlInsert111="INSERT INTO EntryVal (SNAME, FNAME, MNAME,BIRTHD) VALUES ('" & SNAME & "', '" & FNAME & "', '" & MNAME & "', '" & BIRTHD & "') "

sqlInsert11="INSERT INTO CanDetails (TITLE, SNAME, FNAME, MNAME, BIRTHD,************, MSTATUS, SORIGIN, NATION, ADDC1, ADDC2, TELNO, EMAIL, INSNAME1, QUAL1, INSDISC1, GRADE1, INSYRAD1, INSYRGR1 ) VALUES ('" & TITLE & "', '" & SNAME & "', '" & FNAME & "', '" & MNAME & "', '" & BIRTHD & "', '" & ************ & "', '" & MSTATUS & "', '" & SORIGIN & "', '" & NATION & "', '" & ADDC1 & "', '" & ADDC2 & "', '" & TELNO & "', '" & EMAIL & "', '" & INSNAME1 & "', '" & QUAL1 & "', '" & INSDISC1 & "', '" & GRADE1 & "', '" & INSYRAD1 & "', '" & INSYRGR1 & "') "

If E2 <> "" Then
sqlInsert1="INSERT INTO CanDetails (INSNAME2, QUAL2, INSDISC2, GRADE2, INSYRAD2, INSYRGR2 ) VALUES ('" & INSNAME2 & "', '" & QUAL2 & "', '" & INSDISC2 & "', '" & GRADE2 & "', '" & INSYRAD2 & "', '" & INSYRGR2 & "') "
End If

If P1 <> "" Then
sqlInsert1="INSERT INTO CanDetails (PROBODY1, PROCERT1, PROYR1) VALUES ('" & PROBODY1 & "', '" & PROCERT1 & "', '" & PROYR1 & "') "
End If

If P2 <> "" Then
sqlInsert1="INSERT INTO CanDetails (PROBODY2, PROCERT2, PROYR2) VALUES ('" & PROBODY2 & "', '" & PROCERT2 & "', '" & PROYR2 & "') "
End If

Set sqlInsertConn = Server.CreateObject("ADODB.Connection")

sqlInsertConn.Open dbconn 

dbconn.execute(sqlInsert111)

dbconn.execute(sqlInsert11)

dbconn.execute(sqlInsert1)

%>
<%
dbconn.close
%>
anybody have any suggestions?


thanks

Reply With Quote
  #2 (permalink)  
Old May 21st, 2004, 12:18 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

That's weird, because you don't have any command objects... I don't think connection.execute generates a command object to execute it... Could this error be in one of your include files?

Brian
Reply With Quote
  #3 (permalink)  
Old May 22nd, 2004, 12:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Was there any line number shown along with the error? could you post that too?

_________________________
-Vijay G
Strive for Perfection<img src="http://messenger.msn.com/MMM2004-05-10_17.47/Resource/emoticons/thumbs_up.gif" alt="Thumbs up">
Reply With Quote
  #4 (permalink)  
Old May 23rd, 2004, 11:02 PM
Authorized User
 
Join Date: May 2004
Location: chennai, , India.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
see the below piece of code
If E2 <> "" Then
sqlInsert1="INSERT INTO CanDetails (INSNAME2, QUAL2, INSDISC2, GRADE2, INSYRAD2, INSYRGR2 ) VALUES ('" & INSNAME2 & "', '" & QUAL2 & "', '" & INSDISC2 & "', '" & GRADE2 & "', '" & INSYRAD2 & "', '" & INSYRGR2 & "') "
End If

If P1 <> "" Then
sqlInsert1="INSERT INTO CanDetails (PROBODY1, PROCERT1, PROYR1) VALUES ('" & PROBODY1 & "', '" & PROCERT1 & "', '" & PROYR1 & "') "
End If

If P2 <> "" Then
sqlInsert1="INSERT INTO CanDetails (PROBODY2, PROCERT2, PROYR2) VALUES ('" & PROBODY2 & "', '" & PROCERT2 & "', '" & PROYR2 & "') "
End If


If E2 or P1 or p2 field is null means then the empty sqlInsert1 string executed against the Dbconn.execute show the error araises
show u can code like this



If P2 <> "" Then
dbconn.execute("INSERT INTO CanDetails (PROBODY2, PROCERT2, PROYR2) VALUES ('" & PROBODY2 & "', '" & PROCERT2 & "', '" & PROYR2 & "') "
End If
like this this is one way to stop the error
rgs,
Murali.A


Reply With Quote
  #5 (permalink)  
Old May 25th, 2004, 06:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try to print all the variables that you try to execute, to check if that contains the relevant SQL statements.

Code:
Response.write sqlInsert111
Response.write sqlInsert11
Response.write sqlInsert1
Response.end
''''''''''''' before executing them.
dbconn.execute(sqlInsert111)
dbconn.execute(sqlInsert11)
dbconn.execute(sqlInsert1)
Hope that helps.

_________________________
-Vijay G
Strive for Perfection
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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
Command Object - commandType error europhreak Classic ASP Basics 7 February 2nd, 2006 04:55 AM
Command text was not set for the command object. deepa12 BOOK: Beginning ASP 3.0 5 November 2nd, 2004 05:37 PM
command object scrolling qwprince Classic ASP Databases 3 July 24th, 2003 09:29 AM



All times are GMT -4. The time now is 03:17 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.