我目前正在使用PHP 5.2
和Microsoft Server 2008 R2
,并使用sqlsrv和SQL本机客户端10.0。
我已将php扩展名更改为包含extension=php_sqlsrv_52_ts_vc6.dll
,并对php.ini
进行了必要的更改。
php.info
页面还显示sqlsrv已成功安装,但我不确定为什么当我尝试使用sqlsrv命令时,它无法连接到SQL Server。这是我的代码。
<?php
$myServer = "MYSERVER\SQLEXPRESS";
$myUser = "sa";
$myDB = "Form";
$conInfo = array('Database'=>$myDB, 'UID'=>$myUser);
$conn = sqlsrv_connect( $myServer, $conInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>
显示[Microsoft] [SQL Server Native Client 10.0] [SQL Server]用户'sa'登录失败。 [信息]。有人能够善意地告诉我出现了什么问题吗?
我迫切需要答案。谢谢。
答案 0 :(得分:0)
Try with this -
<?php
$myServer = "MYSERVER\SQLEXPRESS";
$myUser = "sa";
$myDB = "Form";
$conInfo = array('Database'=>$myDB, 'UID'=>$myUser, 'PWD'=>'');
$conn = sqlsrv_connect( $myServer, $conInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>