0
votes

I am using php 5.3.1 to connect to my SQL SERVER 2000 on remote machine. I use Windows XP. On using simple program like this:

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

I get following error:

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

I enabled TCP/IP and named pipes in my SQL SERVER and restarted it. Also its Authentication is set to Mixed Mode Authentication.

I can see my server through MS SQL Server Management Studio. So what am I missing here ?

Thanks in advance.

P.S. I have another server in SQL SERVER 2008 to which I can easily connect with the same above mentioned connection string.

EDIT: According to this post, I fired sqlcmd -S np:\\VBNET\pipe\sql\query -U sa in cmd and entered the password and that worked !!! So now what could be the problem. I am at my wits end...please help !!

1
Did you try if it works if you connect to a network share on the server? - bummi
@bummi-can u elaborate as I am new to SQL SERVERs... - Name is Nilay
IIRC SQLServer 2000 needed some kind of Windows trust, you could try to connect from your client to a shared drive on your sql server. - bummi
@bummi-Sorry I couldnt understand you...r u talking about Authentication mode ?? - Name is Nilay
no, it's long ago I used SQL-Server 2000 and I believe to remeber that there was a problem if you wanted to connect as SQL-User e.g. sa without having established an authorization with e.g. connection a share on the server. If it won't work in your environment, my remembrance might be wrong - bummi

1 Answers

1
votes

If you can connect using SSMS, then copy the connection exactly, i.e. make sure you specify a named instance (e.g. 'VBNET\SQLSERVER'). Open SSMS, on the server node on the left side right click and select 'Properties'.

If you have SQL 2008 running on the same machine it is most likely that SQL 2008 uses the default instance and SQL 2000 a named instance.

What also could help, i.e. make testing simpler is to create an empty UDL file (e.g. 'TEST.UDL'). An empty text file should do. Then double click on it, select the provider and play around with the settings. You can always test the connection using the 'Test connection' button. I use this trick when I have to connect from a customer PC for the first time.