22,210
社区成员
发帖
与我相关
我的任务
分享
$conn=new COM('ADODB.Connection') or die('连接错误');
$myDSN="Provider=SQLNCLI.1;Persist Security Info=True;Data Source=localhost;User ID=sa;Password=sasa;Initial Catalog=db_php";
$conn->open($myDSN) or die('连接语句无效');
$sql="select * from [username]";
$rs=$conn->execute($sql);
if($rs->eof()){
print('没有任何数据');
}else{
while(!$rs->eof()){
echo $rs->fields[0]->value;
$rs->movenext();
}
}
--先试试CMD
-->net start mssqlserver
Provider=SQLNCLI.1;Persist Security Info=True;Data Source=localhost;User ID=sa;Password=sasa;Initial Catalog=db_php
SQLNCLI 是指sql native client 驱动,为sqlserver2005协议
Provider=SQLOLEDB.1是为sqlserver2000协议
试一下
Provider=SQLOLEDB.1
Data Source=(localhost)
Provider=SQLNCLI.1;Persist Security Info=false;Data Source=(localhost);User ID=sa;Password=sasa;Initial Catalog=db_php