Passing Parameters By Reference to a COM Object function... Nasty!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear All,

I've got a nasty little problem here I hope someone can help me...

I'm doing a job which requires me to use a 3rd party COM component to
connect to a MSSQL Server. This works by calling Stored Procedures in the
MSSQL DB and returning them in an ADO RecordSet.

The VB Declaration of the COM object function I use is:

<boolean> = DBRequest(ByRef responseDB as Variant, ByRef ErrorStr as
Variant, database as String, Procedure as String, ParamArray paramlist() as
Variant)


I have written 2 test scripts one in ASP VBScript and one in PHP. The
VBScript one works fine but the PHP one doesn't. I have pretty much
definitively established that the problem with the PHP script is that the
RecordSet being passed in by reference is not happening.

Both examples (given below) connect successfully to the DB via the COM
object and execute the specified Stored Procedure. The PHP ADO Recordset
parameter is still empty after the function call. I have also forced an
error by calling a non-existent SP and confirmed that the Error String
parameter, (also passed in by reference) is empty in PHP and not in ASP.


So my question is... HOW DO I PASS A PARAMETER BY REFERENCE TO A COM OBJECT
FUNCTION IN PHP?



<<<<< ASP EXAMPLE >>>>>
<%@ Language=VBScript %>

<%
Dim VBDB
Dim RecSet
Dim RetVal
Dim sDatabase
Dim sError

Set RecSet= Server.CreateObject("ADODB.RecordSet")
Set VBDB = Server.CreateObject("VBDBClientProtocol.msgProtocol")

VBDB.LocalHostIP = "127.0.0.1"
VBDB.RemotePort = 6667
VBDB.RemoteHostIP = "127.0.0.1"

RetVal = VBDB.DBRequest(RecSet, sError, "Oort", "osp_get_Regions")

If RetVal Then
 While (Not RecSet.EOF)
  Response.Write RecSet.Fields(0).Value
  Response.Write "<br>"
  Response.Write RecSet.Fields(1).Value
  Response.Write "<br>"

  RecSet.MoveNext
 Wend

 RecSet.Close
Else
 Response.Write sError
End If

VBDB.Disconnect

Set VBDB = Nothing
Set RecSet = Nothing

%>



<<<<< PHP EXAMPLE >>>>>

<?php

$VBDB = new COM("VBDBClientProtocol.msgProtocol");
$VBDB->LocalHostIP = "localhost";
$VBDB->RemotePort = 6667;
$VBDB->RemoteHostIP = "localhost";

$rs = new COM("ADODB.Recordset");
$sError = "";

$ReqSuccessful = $VBDB->DBRequest(&$rs, &$sError, "Oort",
"osp_get_Regions");

if ($ReqSuccessful)
{
 while (!$rs->EOF)
 {
  echo $rs->Fields["inRegion"]->value . "<br>";
  echo $rs->Fields["vcName"]->value . "<br>";
  $rs->MoveNext();
 }
}

$rs->Close();
$rs = null;
$VBDB->Disconnect();
$VBDB = null;

?>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux