2012-11-09 22 views
0

Possible Duplicate:
Cannot connect to SQL SERVER 2000不能用PHP

我使用PHP 5.3.1連接到遠程計算機上的我的SQL SERVER 2000連接到SQL Server 2000。我使用Windows XP。 使用簡單的程序是這樣的:

$conn = mssql_connect("VBNET","sa","anythinghere") or die ('Can not connect to server'); 

我獲得以下錯誤:

Warning: mssql_connect() [function.mssql-connect]: message: Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection. (severity 14) in C:\wamp\www\Mssql\test.php on line 8

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: VBNET in C:\wamp\www\Mssql\test.php on line 8 Can not connect to server

我啓用TCP/IP和命名管道在我的SQL Server並重新啓動它。其身份驗證也設置爲混合模式身份驗證。那麼我在這裏錯過了什麼?

在此先感謝。

編輯這個問題是第一次有關SQL Server 2008,但後來它被帶到我所知,這是SQL Server 2000中請原諒我我的無知,但問題依然存在。所以請給我建議。

回答

1

This problem occurs when the SQL Serversecurity authentication is set to Windows only, and one of the following conditions is true:

  • You are trying to connect to a SQL Server database with a SQL Server login.
  • You are trying to connect to a SQL Server 2000 Desktop Engine (also known as MSDE 2000) database that is installed on a Microsoft Windows 98-based computer by using a trusted SQL Server connection.
  • You are trying to connect to a SQL Server database from a Windows account that does not have sufficient permissions to connect to the
    server.

To work around this problem, use one of the following methods depending on the symptom that you are experiencing:

- A SQL Server login

Use a valid Windows login to connect to SQL Server. If you must continue to use a SQL Server login, you can change the security authentication mode in SQL Server to SQL Server and Windows. To do this, follow these steps:

  1. Start Enterprise Manager.
  2. Expand Microsoft SQL Servers, and then expand SQL Server Group.
  3. Right-click the server that you want to change to SQL Server and Windows authentication, and then click Properties.
  4. In the SQL Server Properties dialog box, click the Security tab, click SQL Server and Windows, and then click OK.
  5. When you are prompted to re-start the SQL Server service, click Yes.

- A Windows account with insufficient permissions

To work around this problem, you must add the Windows account to SQL Server, and then grant the appropriate permissions to each database that the user requires access to. To do this in SQL Server 2000, follow these steps:

  1. Start Enterprise Manager.
  2. Expand Microsoft SQL Server, and then expand SQL Server Group.
  3. Expand your server, and then expand Security.
  4. Right-click Logins, and then click New Login.
  5. In the SQL Server Login Properties dialog box, enter the Windows account name in the Name box. In the Domain list, select the domain that the Windows account is a member of.
  6. Click the Database Access tab, set the appropriate permissions for the client, and then click OK.

http://support.microsoft.com/kb/889615

+0

@ hermann - 我們的服務器模式設置爲混合模式身份驗證,並且我被提供足夠的權限......因此可能會出現什麼問題? –

+0

@NilayOnAndroid你找到了解決你的問題?嘗試使用此設置。嘗試將其設置爲僅用於服務器身份驗證(如果存在這種情況)。 – hermann

+0

@ hermann-我最近發現我的服務器實際上是SQL SERVER 2000而不是2008 ..這可能是問題嗎?如果是,比可以解決什麼? –

2

請參閱Microsoft知識庫文章889615獲取解決方案。我發現這是通過Google搜索您的錯誤消息:「與受信任的SQL Server連接關聯」。

+0

@ Dalyn,我們的服務器模式設置爲混合模式身份驗證和我被提供了足夠的權限...所以什麼都可以的問題? –

+0

@ Dalyn-請參閱我編輯的問題 –

+0

請查看與此相關的可能重複問題,看看是否可以解決您的問題。 – thestepafter