Name

CommandText (Command Object) — objCmd .CommandText (= strCommandText )

Synopsis

A string value that represents the actual command you wish to run against the database. The default value for this property is an empty string (""). This command can be a SQL statement or the name of a stored procedure.

Parameters

ocjCmd

A reference to a Command object

strCommandText

A string containing the command you wish to run against the database

Example

The following example demonstrates how to use the CommandText property to invoke a stored procedure with two parameters.

<%@ LANGUAGE="VBSCRIPT" %>
<% Response.Buffer = True %>
<HTML>
<HEAD>
<TITLE>ADO Examples</TITLE>
</HEAD>
<BODY>
<%
' Include ADOVBS.INC so we can use the ADO constants.
%>
<!-- #include virtual = "/bc_SSIncludes/adovbs.inc" -->
<%
' Instantiate an ADO Connection object.
Set objDBConn = Server.CreateObject("ADODB.Connection") 

' Construct the connection string for the Connection object.
strConn = _
   "driver={MyDBType};;uid=sa;pwd=;database=SalesDB"

' Using the connection string, open the connection.
objDBConn.Open strConn

' Create a stored procedure command object
Set objSPCmd = Server.CreateObject("ADODB.Command")

' Set active connection equal to current Connection object.
Set objSPCmd.ActiveConnection = objDBConn

' Set command object type to stored procedure.
objSPCmd.CommandType = adCmdStoredProc

' Set the parameter values.
lngHighPrice = 70000
datFirstDate = "03/02/98"

' Set stored procedure command text. The parameters ' ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.