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]:サーバーに接続できません:17行目のC:...\index.phpのDELL-M102Z\SQLEXPRESS接続を確立できませんでした。

誰かがここで何が問題なのか教えてもらえますか?

4

2 に答える 2

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:ポート';

ここでは、IP とポートにセミコロンが必要であり、Mssql は cpanel で有効化されています

于 2016-05-06T09:52:40.883 に答える