Forum Discussion

frank_vanderstr's avatar
frank_vanderstr
Contributor
7 years ago

ADO Connection Rows Affected by Stored Procedure

I have a script in JScript where I run a stored procedure on a test database, but I want to be able to print the rows affected messages from SQL into the log after running.

 

I have tried a few different methods to obtain the rows affected text, but I have not been able to make any work properly.

 

This is how i established my connection

 

var SprocName = spName
  var dbname = '888800';
  var RowCount;   
  var connectionstring = ADO["CreateADOConnection"]();
  connectionstring["ConnectionString"] = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DB;Data Source=DBServer";
  connectionstring["LoginPrompt"] = false;
  connectionstring["Open"]();
 
  var Cmd = ADO.CreateADOCommand();

Cmd.ConnectionString = connectionstring["ConnectionString"];
  Cmd.CommandType = adCmdStoredProc;
  Cmd.CommandText = SprocName;

var oParmSP = Cmd["Parameters"]["CreateParameter"]("intappid", ftString, adParamInput, "10", dbname);

 

var RecSet;
  var Roweffect;
  var RecordsAffected;

 

var params = new Array();
  params.push(RecordsAffected);
  params.push(Cmd["Parameters"]["ParamValues"]("intappid"));

  var result = OutParameterWrapper.CallObjectMethod(Cmd, "Execute", params).toArray();

  Log.Message(result[0]);

 

I am using the OutParameterWrapper script extension mentioned in an earlier thread which posed a similar question a few years ago. I think where I am stuck is actually getting the Command to execute properly from the CallObjectMethod and setting it up so that I actually get the rows affected value.

 

It has been difficult to find actual coding examples of finding the information I need or setting up the execute call properly. Any help or suggestions will be appreciated.

No RepliesBe the first to reply