Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

On SQL Update: Microsoft JET Database Engine error '80040e0c' - Command text was not set for the command object

Posted on 2004-03-23
22
Medium Priority
?
1,576 Views
Last Modified: 2007-12-19
This is just annoying the heck out of me.
I have an asp page that is trying to update an access database. I can open the table ina recordset and update each record by looping through them, but when I call a SQL to do it I get:

Microsoft JET Database Engine error '80040e0c'
Command text was not set for the command object.

Since I know people will want to see source I broke it down to this, and it fails in a SQL update for me but works fine through the record set...

dim cnn: Set cnn = Server.CreateObject("ADODB.Connection")
dim strCnn: strCnn = "provider=Microsoft.Jet.OLEDB.4.0; data Source=\\psc_dev\PublicDatabase\complant\complant.mdb"
cnn.Open(strCnn)
cnn.execute("UPDATE cmplnt SET NoDupeCheck=True WHERE RecId in (1,2,3,4)"


I have tried setting the connection mode to 3. I have tried adding exec before the update.. I am at a loss here....

Thanks.


0
Comment
Question by:rhawk
  • 10
  • 9
  • 2
  • +1
22 Comments
 
LVL 6

Expert Comment

by:sforcier
ID: 10659756
The parenthasis in the execute method isn't closed, or is that a typo?
0
 
LVL 28

Expert Comment

by:sybe
ID: 10659779
you database is on another machine, are you sure you don't have a permissions issue?
0
 
LVL 2

Author Comment

by:rhawk
ID: 10659781
Typeo. they are closed.
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.

 
LVL 2

Author Comment

by:rhawk
ID: 10659793
Sybe, No that is the machine. I always use UNC to itself.
Oddly I can ADD records and update records through a recordset opening of the table using the same connection string...
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10660631
no colons after variables:

Was:

dim cnn: Set cnn = Server.CreateObject("ADODB.Connection")
dim strCnn: strCnn = "provider=Microsoft.Jet.OLEDB.4.0; data Source=\\psc_dev\PublicDatabase\complant\complant.mdb"

Should be:

dim cnn Set cnn = Server.CreateObject("ADODB.Connection")
dim strCnn strCnn = "provider=Microsoft.Jet.OLEDB.4.0; data Source=\\psc_dev\PublicDatabase\complant\complant.mdb"
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10660655
Actually should be:

dim cnn, strCnn
Set cnn = Server.CreateObject("ADODB.Connection")
strCnn = "provider=Microsoft.Jet.OLEDB.4.0; data Source=\\psc_dev\PublicDatabase\complant\complant.mdb"
0
 
LVL 6

Expert Comment

by:sforcier
ID: 10660745
You had me questioning my sanity for a minute there, alorentz (with that single line declaration/initialization). I think, though, that the colons are just for succinct code reproduction in the post, otherwise they'd be getting a different error.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10660935
Yes, I like the formatting better in my example, but the colons will work.

Which line is the error? Open or Execute?
0
 
LVL 2

Author Comment

by:rhawk
ID: 10661258
Error is on the execute.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10661489
Can you post more code from the page...doesn't look like there should be anything wrong with that.
0
 
LVL 2

Author Comment

by:rhawk
ID: 10661597
This is now the WHOLE page:
<%
dim cnn: Set cnn = Server.CreateObject("ADODB.Connection")
dim strCnn: strCnn = "provider=Microsoft.Jet.OLEDB.4.0; data Source=\\psc_dev\PublicDatabase\complant\complant.mdb"
cnn.Open(strCnn)
cnn.execute("UPDATE cmplnt SET NoDupeCheck=True WHERE RecId in (1,2,3,4)")
%>
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10661726
What datatype is NoDupeCheck?
0
 
LVL 2

Author Comment

by:rhawk
ID: 10661748
Yes/No.
However I also tried to update a text field with "test" to see if that entered into the problem. Same error.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10661859
Does this work?  I know you mentioned it, but please test again!

<%
dim cnn: Set cnn = Server.CreateObject("ADODB.Connection")
dim strCnn: strCnn = "provider=Microsoft.Jet.OLEDB.4.0; data Source=\\psc_dev\PublicDatabase\complant\complant.mdb"
cnn.Open(strCnn)
rs = cnn.execute("Select * from cmplnt WHERE RecId in (1,2,3,4)")
if not rs.eof then
   do until rs.eof
         rs("NoDupeCheck")=True
         rs.update
         rs.movenext
   loop
end if
cnn.close
%>
0
 
LVL 2

Author Comment

by:rhawk
ID: 10662148
alorentz: You left out a set on rs=
No, your code does not work.

But this does:

<%
dim cnn: Set cnn = Server.CreateObject("ADODB.Connection")
dim strCnn: strCnn = "provider=Microsoft.Jet.OLEDB.4.0; data Source=\\psc_dev\PublicDatabase\complant\complant.mdb"
dim rs: set rs = Server.CreateObject("ADODB.RecordSet")
cnn.Open(strCnn)
rs.Open "cmplnt", cnn,adOpenDynamic,adLockOptimistic
'set rs = cnn.execute("Select * from cmplnt WHERE complaint in (26876, 26875, 26874)")
if not rs.eof then
   do until rs.eof
         rs("NoDupeCheck")=True
         rs.update
         rs.movenext
   loop
end if
cnn.close
%>
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10662190
The code I gave is correct...you do not need SET when used like that...

Try my code again, just as it is....
0
 
LVL 2

Author Comment

by:rhawk
ID: 10662195
GGGRRRRR!! THis also works!

<%
dim cnn: Set cnn = Server.CreateObject("ADODB.Connection")
dim strCnn: strCnn = "provider=Microsoft.Jet.OLEDB.4.0; data Source=\\psc_dev\PublicDatabase\complant\complant.mdb"
dim rs: set rs = Server.CreateObject("ADODB.RecordSet")
cnn.Open(strCnn)
rs.Open "Select * from cmplnt where Complaint in (26876,26875,26874)", cnn,adOpenDynamic,adLockOptimistic
if not rs.eof then
   do until rs.eof
         rs("NoDupeCheck")=False
         rs.update
         rs.movenext
   loop
end if
cnn.close
%>

I may just pack it in and do the select in the RS open... I have to get this up. Unless someone can give me a fix before end of day... I'll up the points also now...
0
 
LVL 2

Author Comment

by:rhawk
ID: 10662215
alorentz: I did try it (I changed id to complaint as I renamed the field.

Your code failed on the rs=. I put the set on the line and it passed that line but gave me the exact same error I first posted....
0
 
LVL 2

Author Comment

by:rhawk
ID: 10662239
Alorentz:

Your code unchanged gives this result:
  Microsoft VBScript runtime error '800a01b6'
  Object doesn't support this property or method: 'rs.eof'
  /Utility/Complaints/test.asp, line 6

Your code with the set:
  ADODB.Recordset error '800a0cb3'
  Object or provider is not capable of performing requested operation.
  /Utility/Complaints/test.asp, line 8


Line 8 is the assignment...

THe code I just posted works.... Explain that?!
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10662441
Doing it like that works because of the Locking , and CursorLocation attributes:

cnn,adOpenDynamic,adLockOptimistic

Not sure why the Execute doesn't work though....

What's the error again with this:

<%
dim cnn: Set cnn = Server.CreateObject("ADODB.Connection")
dim strCnn: strCnn = "provider=Microsoft.Jet.OLEDB.4.0; data Source=\\psc_dev\PublicDatabase\complant\complant.mdb"
cnn.Open(strCnn)
cnn.execute("UPDATE cmplnt SET NoDupeCheck=True WHERE RecId in (1,2,3,4)")
%>

0
 
LVL 2

Author Comment

by:rhawk
ID: 10662580
I am getting very mad here. That now works! Clearly it is the exact same code you 1st sent me and exactly what I posted (save the paren I left off).

However I did reboot the server about an hour ago... One wonders.

I need to look into this more, but I am about to go home for the night. I'll ponder it tonight and retry in the morning...
0
 
LVL 31

Accepted Solution

by:
alorentz earned 2000 total points
ID: 10662748
Rebooting the server should've fixed it, I read that somewhere about a 1/2 hour ago...was going to mention but my wife got home!  You know how it goes...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question