2

任何人都可以从以下参数中解释连接字符串:

server IP : 192.168.137.4
Windows Authentication : Windows Authentication
UserName : DELL-M102Z\dell
Database : DataProd 
Network Protocol : <default>
Product Name : Microsoft SQL Server Express Edition
Server Name : DELL-M102Z\SQLEXPRESS
Instance Name : SQLEXPRESS
Computer Name : DELL-M102Z

我试过:

$serverName = "DELL-M102Z\SQLEXPRESS"; //serverName\instanceName
$username = "DELL-M102Z\dell"; //serverName\instanceName
$conn = mssql_connect( $serverName,$username,'');

...但我得到的结果是:

警告:mssql_connect() [function.mssql-connect]: Unable to connect to server: DELL-M102Z\SQLEXPRESS in C:...\index.php on line 17 无法建立连接。

谁能告诉我这里有什么问题?

4

2 回答 2

2

尝试执行此步骤: http: //michaelellerbeck.com/2010/03/31/cant-connect-remotely-to-sql-server-2008/ 我知道我错过了激活 sql 浏览器服务,这就是为什么我不能通过远程IP连接,

我从那个网站得到了结论,我必须确保:

1. make sure you have allow network connection from sql server configuration tool
2. allow connection for this port in firewall
3. activate sql browser service
4. make sure port is listen as the the service provide

我遇到了 3 号问题,我被困住了,这个网站解决了这个问题: http: //www.wikihow.com/Enable-Remote-Connections-SQL-2008-Express

于 2012-11-28T06:09:15.700 回答
2
<?php
$myServer = 'xxx.xxx.xxx.xxx:yyyy';
$myUser = 'sa';
$myPass = 'xxxxx';

$con = mssql_connect($myServer, $myUser, $myPass) or die("Could not connect to database: ".mssql_get_last_message()); 
if($con){
echo "connected";
}
// Select a database:
mssql_select_db('new') 
    or die('Could not select a database.');

// Example query: (TOP 10 equal LIMIT 0,10 in MySQL)
$SQL = "SELECT TOP 10 * FROM Table";

// Execute query:
$result = mssql_query($SQL) 
    or die('A error occured: ' . mysql_error());

// Get result count:
$count = mssql_num_rows($result);
print "Showing $count rows:<hr/>\n\n";

// Fetch rows:
while ($Row = mssql_fetch_assoc($result)) {

    print $Row['BillNo'] . "\n";

}

mssql_close($con);

$myServer = 'IP_Address:PORT';

这里分号需要 ip 和 port 并且 Mssql 在你的 cpanel 中被 enbaled

于 2016-05-06T09:52:40.883 回答