The Command property of the QueryAdapter is a string, not an object, which is
why you are getting the error, since the OUTPUT parameter cannot be returned.
You will not be able to retrieve an output value returned by a stored
procedure by using this Command property. You need to use the Command object
of ADODB (see http://support.microsoft.com/?kbid=185125).
For JScript, you would have to instantiate a Command object like this:
var objCommand = new ActiveXObject("ADODB.Command");
Then set the ActiveConnection and fill the Parameters collection on the
Command object, call Execute on the Command object, close the connection,
refresh the Parameters collection, and then retrieve the value of the output
parameter.
---
S.Y.M. Wong-A-Ton
> I have a sp that has one input parameter (Piece char(7)) and one output
> parameter (Cost )...the sp works fine but I can't figure out how to:
[quoted text clipped - 33 lines]
> and I get : Cannot use the OUTPUT option when passing a constant to a stored
> procedure
BFSmith - 04 Mar 2006 17:41 GMT
wow...that's a mouthfull...any chance you have a js example of such a beast?
> The Command property of the QueryAdapter is a string, not an object, which is
> why you are getting the error, since the OUTPUT parameter cannot be returned.
[quoted text clipped - 49 lines]
> > and I get : Cannot use the OUTPUT option when passing a constant to a stored
> > procedure
S.Y.M. Wong-A-Ton - 05 Mar 2006 15:55 GMT
var conn = new ActiveXObject("ADODB.Connection");
conn.ConnectionString = "driver={sql
server};server=(local);database=YourDBName;uid=sa;pwd=;";
conn.Open();
var cmd = new ActiveXObject("ADODB.Command");
cmd.ActiveConnection = conn;
cmd.CommandText = "your_stored_proc_name";
cmd.CommandType = 0x0004; // adCmdStoredProc
var param = new ActiveXObject("ADODB.Parameter");
param.Name = "@output_parameter";
param.Direction = 0x0002; // adParamOutput
param.Type = 3; // adInteger
cmd.Parameters.Append(param);
var param2 = new ActiveXObject("ADODB.Parameter");
param2.Name = "@input_parameter";
param2.Direction = 0x0001; // adParamInput
param2.Type = 200; // adVarChar
param2.Size = 10;
param2.Value = "testing123";
cmd.Parameters.Append(param2);
var parameters;
var recs;
cmd.Execute(recs, parameters);
conn.Close();
cmd.Parameters.Refresh;
XDocument.UI.Alert(cmd.Parameters[0].Value); // Retrieve output param value
----
For a sample ODBC connection string corresponding to your database type look
on
http://www.connectionstrings.com
Look on http://www.winscripter.com/ASP/Database/46.aspx to find the correct
ADO constants (such as adChar or adVarChar, etc.) in JScript for the data
types used in your stored procedure.
You might experience ADO security issues when running this code. Perhaps you
should look into using web services
(http://msdn.microsoft.com/library/en-us/odc_ip2003_ta/html/OfficeInfoPathWebServ
iceASPNET.asp?frame=true) if this does not work for you.
---
S.Y.M. Wong-A-Ton
> wow...that's a mouthfull...any chance you have a js example of such a beast?
>
[quoted text clipped - 51 lines]
> > > and I get : Cannot use the OUTPUT option when passing a constant to a stored
> > > procedure