Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

php_com_dotnet - can not create VT_ERROR variant type #8750

Closed
@systoolz

Description

@systoolz

Description

Can not create VT_ERROR variant type. It's required for some COM method calls where you need to specify an empty argument, since it's VT_ERROR type variant with error DISP_E_PARAMNOTFOUND (0x80020004) as actual error code (see here).

The following code:

<?php// database.php// next line works only in PHP 4.4.9 (PHP 5, 6, 7 and 8 are bugged)$vtMissing =newVARIANT(0x80020004,VT_ERROR);$db =newCOM('ADODB.Connection');$db->ConnectionString ='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database.mdb';$db->Mode =1;// adModeRead$db->Open();// adSchemaProviderSpecific, *missing*, JET_SCHEMA_USERROSTER$rs =$db->OpenSchema(-1,$vtMissing,'{947bb102-5d43-11d1-bdbf-00c04fb92675}');// manual counting since rs.RecordCount is -1 (not supported)$i =0;while (!$rs->EOF) {$rs->MoveNext();$i++;  }$rs->Close();$rs =null;$db->Close();$db =null;echo$i;

Resulted in this output:

Fatal error: Uncaught com_exception: Variant type conversion failed: Type mismatch in Z:\database.php:3Stack trace:#0 Z:\database.php(3): variant->__construct(2147614724, 10)#1 {main}  thrown in Z:\database.php on line 3

But I expected this output instead:

1

Test file "database.mdb" can be any Microsoft Access database file, even without any tables inside.
More details can be found in this article (auto-translated from Russian):
VT_MISSING argument in PHP for COM objects

PHP Version

PHP 8.1.7 x64

Operating System

Windows 7 x64

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp