php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6683 Cannot pass COM object as parameter to another COM object
Submitted: 2000-09-12 12:21 UTC Modified: 2001-01-29 21:11 UTC
From: jlim at natsoft dot com dot my Assigned: phanto (profile)
Status: Closed Package: COM related
PHP Version: 4.0.2 OS: Windows 98
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jlim at natsoft dot com dot my
New email:
PHP Version: OS:

 

 [2000-09-12 12:21 UTC] jlim at natsoft dot com dot my
This example creates a connection object to a database, creates a recordset, then assigns the connection object to the recordset using ADO com objects.

<?
$dbc = new COM('ADODB.Connection');
$dbc->Provider = 'MSDASQL';
$dbc->Open('NWIND'); // standard sample access database northwind
$rs = new COM("ADODB.Recordset");
$rs->Open('select * from product',$dbc,3); // 3 = static cursor
?>


OUTPUT ERROR MESSAGE:

Warning: Invoke() failed: Exception occurred. in d:\Inetpub\wwwroot\php\bugado.php on line 6
PHP has encountered an Access Violation at 78002D15

The error is because the COM object $dbc is passed as a parameter to $rs.

I have the same code in ASP. Works fine.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-12 19:09 UTC] jlim at natsoft dot com dot my
This example creates a connection object to a database, creates a recordset, then assigns
the connection object to the recordset using ADO com objects.

<?
$dbc = new COM('ADODB.Connection');
$dbc->Provider = 'MSDASQL';
$dbc->Open('NWIND'); // standard sample access database northwind
$rs = new COM("ADODB.Recordset");
$rs->Open('select * from product',$dbc,3); // 3 = static cursor
?>


OUTPUT ERROR MESSAGE:

Warning: Invoke() failed: Exception occurred. in d:\Inetpub\wwwroot\php\bugado.php on line
6
PHP has encountered an Access Violation at 78002D15

The error is because the COM object $dbc is passed as a parameter to $rs.

I have the same code in ASP. Works fine.


=========================

I have found the problem in COM.c

443 static void php_pval_to_variant(pval *pval_arg, VARIANTARG *var_arg)
444 {
445         OLECHAR *unicode_str;
446 
447         switch (pval_arg->type) {
448         case IS_OBJECT:
449         case IS_ARRAY:
450                 var_arg->vt = VT_EMPTY;
451                 break;

if IS_OBJECT, should check if it is COM object, and set var_arg->vt as appropriate

John
 [2001-01-29 17:19 UTC] phanto@php.net
working on it
 [2001-01-29 21:11 UTC] phanto@php.net
fixed in cvs now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 21:01:30 2024 UTC