首页 > 解决方案 > 查询windows索引时出错:传递给系统调用的数据区太小

问题描述

我在服务器 2019 pc 上查询 windows 索引时遇到问题。

我正在尝试使用 SQL 和 adodb 连接查询系统索引。当我使用contain运算符时,代码可以工作,但是当我使用like运算符时,它会引发错误。

index.php 文件中的代码是:

<?php
$conn = new COM("ADODB.Connection",null,CP_UTF8) or die("Cannot start ADO");
$recordset = new COM("ADODB.Recordset"); 
$conn->Open("Provider=Search.CollatorDSO.1;Extended Properties='Application=Windows';");
?>
<!DOCTYPE html>

<html lang="el">
<head>
<meta http-equiv="content-type" content="text/html">
<meta charset="utf-8">
<title>Index Search</title>

</head>
<body>
<h2 style="text-align: center;">ΑΝΑΖΗΤΗΣΗ</h2>
<div class="srchcontainer">
<form action="" method="post">
Γράψε λεκτικό: <input type="text" name="term" />
<input type="submit" value="Αναζήτηση" />
<br><br>
Πλήθος αποτελεσμάτων: <input type="number" name="resultNumber" value="<?php echo                         
$_POST['resultNumber'];?>"/>
</form>
</div>
<ol>
<?php
if(!empty($_POST['resultNumber'])){
$resultNumber=$_POST['resultNumber'];}
else {
$resultNumber=10;}
if(!empty($_POST['term'])){
$term = iconv('UTF-8','ISO-8859-7',$_POST['term']);

//$recordset->Open("SELECT top ".$resultNumber." System.itemPathDisplay FROM SYSTEMINDEX WHERE CONTAINS ('".$term."*')", $conn); this is working but i need the like operator

$recordset->Open("SELECT top ".$resultNumber." System.itemPathDisplay FROM SYSTEMINDEX WHERE System.itemName like '%".$term."%'",$conn);  // here is the problem with the like operator

if(!$recordset->EOF) $recordset->Movefirst(); //here is the line that breaks

while(!$recordset->EOF) {

$viewfile=iconv('ISO-8859-7','UTF-8',$recordset->Fields->Item('System.ItemPathDisplay')->Value);

echo '<li><a href="'.$viewfile.'">'.$viewfile.'</a></li>';
$recordset->MoveNext();
}
$recordset->close();    
}

?>
</ol></div>
</body>
</html>

错误是:

在此处输入图像描述

有人知道为什么不能使用 like 运算符吗?或者我怎么能研究这个错误?

操作系统:Windows 服务器 2019,

使用最新 laragon 创建的本地服务器

谢谢你。

标签: phpwindows-search

解决方案


推荐阅读