致命错误:类“COM” 尝试使用 ADODB 时未找到
include('adodb5/adodb.inc.php');
$myServer = "localhost";
$myUser = "root";
$myPass = "root";
$myDB = "database";
//create an instance of the ADO connection object
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
//define connection string, specify database driver
$connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;
$conn->open($connStr); //Open the connection to the database
这是我第一次遇到 ADODB 库,据说它会帮助我从 MySQL 切换到 Microsoft SQL Server。 有谁知道为什么我会收到此错误,或者是否有一种更简单的方法,不涉及使用 php.ini 文件?
include('adodb5/adodb.inc.php');
$myServer = "localhost";
$myUser = "root";
$myPass = "root";
$myDB = "database";
//create an instance of the ADO connection object
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
//define connection string, specify database driver
$connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;
$conn->open($connStr); //Open the connection to the database
This is the first time I have come across the ADODB library and it supposedly is going to help me switch over from MySQL to Microsoft SQL Server. Does anyone know why i am getting this error or if there is a simpler way that does not involve playing around with the php.ini file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想使用以下代码:
您需要在 PHP 中启用“COM 支持”,例如使用 com_dotnet 扩展 (php_com_dotnet.dll) 如何安装COM扩展
If you want to use following code:
you need to enable "COM support" in PHP, such using the com_dotnet extension (php_com_dotnet.dll) How to install COM extension
看来您包含了 PHP adodb 库,但实际上并没有使用它 - 而是尝试实例化(微软)ADO COM 对象。
如果您没有安装 ADO/从 PHP 工作,您可以尝试使用 ODBC DSN-less 连接,例如:
另请参阅 http://phplens.com/adodb/code.initialization.html#connect_ex
It seems that you are including the PHP adodb library, but then not actually using it - instead trying to instanciate a (microsoft) ADO COM object.
If you don't have ADO installed / working from PHP you could try using an ODBC DSN-less connection like:
Also see other connection examples at http://phplens.com/adodb/code.initialization.html#connect_ex
最可能的原因是服务器上未正确安装 ADO。 尝试运行最新版本的 MDAC 并确保其安装正确,然后重新尝试。 使用更多信息更新您的问题以获取更多详细信息。 我假设您使用的是 Windows Server?
The most likely cause is that ADO is not correctly installed on the server. Try running the latest version of MDAC and insure it install correctly then try agin. Update your question with more information for further details. I assume you are on a Windows Server?