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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't make an ADOCommnad.Execute work in IE 5

Status
Not open for further replies.

guille

Programmer
Aug 13, 1999
1
PE
I'm beginning in VBScript, and tried a simple update query using SQL, but it doesn't work... on the line that calls the Execute of the ADOCommand.<br>
<br>
is there something else I have to download or it's only that my code is all wrong?<br>
<br>
Thanx<br>
<br>
Guille
 
Doesn't ADO provide a read-only recordset by default? I think that you have to set the locking to optimistic?
 
The Command object doesn't support an Execute method. In it's simpliest iteration, to update a DB with ADO...<br>
<br>
Dim oConn, strSql, strConn<br>
oConn = Server.Createobject("ADODB.Connection")<br>
strConn = "DSN=Northwind;uid=sa;pwd=;"<br>
oConn.Open strConn<br>
strSql = "UPDATE customers SET contactname = 'Jeff' WHERE customerId = 'ALFKI'"<br>
oConn.Execute strSql<br>
oConn.Close<br>
Set oConn = Nothing<br>
<br>
<br>
Note: I did not have to use the Command object, instead I called the execute method on the Connection object. FYI the command object is used primarily to optimize the command by setting command properties, (CommandType, CommandTimeout, etc.) and to access the Parameter collection if you're using stored procedures (although you don't really even need to do that to use stored procedures). You could optimize your ADO by creating a command object and then setting the ActiveConnection property and CommandType properties appropriately.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>

 
I tried using the above code and I get a server error. On the oConn = Server.CreateObject(&quot;ADODB.Connection&quot;) line. Am I doing something wrong ?<br>
<br>
Please reply to <A HREF="mailto:jbaker@tmctech.com">jbaker@tmctech.com</A><br>
<br>
Thanks<br>
-Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top