警告:odbc_connect():SQL错误:[Microsoft] [ODBC驱动程序管理器]找不到数据源名称,也未指定默认驱动程序 [英] Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

查看:1357
本文介绍了警告:odbc_connect():SQL错误:[Microsoft] [ODBC驱动程序管理器]找不到数据源名称,也未指定默认驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Access数据库连接到PHP文件. PHP文件给出错误

I have connect Ms Access Database to PHP File. PHP file Give Error

警告:odbc_connect():SQL错误:[Microsoft] [ODBC驱动程序管理器]

"Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager]

未找到数据源名称且未指定默认驱动程序,第3行中C:\ wamp \ www \ PI \ Connection.php中SQLConnect中的SQL状态IM002.

Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\wamp\www\PI\Connection.php on line 3".

Connection.php

Connection.php

<?php
$con = odbc_connect("PIInstitute","","");
if($con){
    echo "Connected";
}else{
    echo "Failed";
}
?>

推荐答案

在调用odbc_connect()时,您需要指定驱动程序,如下所示:

You need to specify your driver when calling odbc_connect() like so:

$conn =  odbc_connect ( "Driver={SQL Server};Server=$servername;Database=$dbname;", $username, $password ) or die ( "Connection failed: " . $conn );

您可以在odbc_connect()上找到更多信息: http://php.net/manual/en/function.odbc-connect.php

You can find more info on odbc_connect()here: http://php.net/manual/en/function.odbc-connect.php

这篇关于警告:odbc_connect():SQL错误:[Microsoft] [ODBC驱动程序管理器]找不到数据源名称,也未指定默认驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆