Calling Stored Procedures

There are a several ways to call stored procedures with this class.

Take the following dummy stored procedure:

CREATE PROCEDURE test 
  @cName varchar(30),
  @iResult int OUTPUT
AS

select * from wws_customers where company like @cName

Set @iResult = 10
GO

The official way is the following:

oSQL = CREATEOBJECT("wwADOSql") * oSQL.nCodepage=65001 && UTF-8 oSQL.Connect("Provider=sqloledb;Data Source=(local);Initial Catalog=WebStore;Integrated Security=SSPI") oSQL.AddParameter("W%","cName") oSQL.AddParameter(0,"iResult","OUT") && Output parameter lnResult = oSQL.CallStoredProcedure("test") if lnResult = -1 ? oSQL.cErrorMsg RETURN && Errro ENDIF *** Retrieve a parameter lnResultValue = oSQL.oParameters["iResult"].Value *** Cursor returned from the SELECT BROWSE

The above is the most effective way and gives you the most control over parameter types. You can actually specify each parameters type and width, size etc.

You can also use Visual FoxPro SQL Passthrough syntax like the following:

cName = "W%" iResult = 0 oSQL.CallStoredProcedure("exec TestNoOutParms ?cName,?@iResult") ? iResult ? o.Parameters["iResult"].Value

Note the following:



  Last Updated: 4/29/2008 | © West Wind Technologies, 2008