p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: Using the Command Object's Execute Method with Jscript


Message #1 by Bobby Johnson <bobby@s...> on Wed, 23 May 2001 09:30:31 -0700
I am attempting to use the Command Object's Execute method in jscript. The
execute seems to work but the number of records affected is not returned 
to the variable. The variable remains undefined.

I have posted this question in Beginning ASP but have yet to receive a
response in 4 days, so I hope I can get pointed in the right direction here.
I have attempted to find my own answer and have found the following articles
that seem to explain how to do it:

http://www.devguru.com/Technologies/ado/quickref/command_execute.html
http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/dasdk/mdao2o
f9.htm

I have come to the conclusion that this is a limitation of jscript. But as
with most limitations there is normally a way around it. Can anyone assist
me in determine the records affected by a command object?

Code below:


<%@ language=javascript %> 
<!-- #include file="datastore.asp" --> 
<!-- metadata type="typelib" file="C:\Program Files\Common
Files\System\ado\msado15.dll" --> 
<html> 
<head> 
   <title>Using SQL's UPDATE Command and the ADO COmmand Object</title> 
</head> 

<body> 
<% 
var objComm,intNoOfRecords; 
objComm=Server.CreateObject("ADODB.Command"); 

Response.Write("<B>Harry the Ham directs Tarantino films?</b><BR>"); 
objComm.ActiveConnection=cmdOpen; 
objComm.CommandText="UPDATE AllMovies SET Director = 'Harry the Ham' WHERE
Director LIKE 'Quentin Tarantino'"; 
objComm.CommandType=adCmdText; 
objComm.Execute(intNoOfRecords); 
Response.Write("This UPDATE command has affected "+intNoOfRecords+"
records<BR><BR>"); 

Response.Write("<B>Tarantino returned to his rightful place as
director:</b><BR>"); 

objComm.CommandText="UPDATE AllMovies SET Director = 'Quentin Tarantino'
WHERE Director LIKE 'Harry the Ham'"; 

objComm.Execute(intNoOfRecords); 

Response.Write("This UPDATE command has affected "+intNoOfRecords+"
records<BR><BR>"); 

objComm=null; 



%> 
<!-- #include file="visitorcount.asp" --><br> 
<a href=showfile.asp?page=sqlupdate.asp>Want to see the code that generated
this page?</a> 

</body> 
</html> 

	



	



  Return to Index