0

I'm using Windows Server 2003 R2 and SQL Server 2000 and I'm attempting to connect to to my database from another PC in the same Network (Also using Win Server 2003 R2) But I'm getting SQLSTATE[28000] SQLDriverConnect: 18452 [Microsoft][ODBC SQL Server Driver][SQL Server]

It says it not on a Trusted Connection.

I read in the Microsfot Docs that this error ONLY occurs when using Windows Authentication Only, BUT I'm currently using Mixed Authentication.

I'm using PHP PDO to connect this is my connection string:

$conn = new PDO("odbc:Driver={SQL Server};Server=MyServer;Database=MyDB","sa","pass");

This connection string currently works with SQL SERVER 7, But it doesn't with SQL SERVER 2000. Do You know any workarounds? or maybe... How to created a Trusted Connection?

Gabriel Matusevich
  • 3,835
  • 10
  • 39
  • 58

1 Answers1

0

You need to add ";Integrated Security=SSPI" or ";Trusted_Connection=Yes" - I forget which one. SSPI relates to "just use the current user", whereas the other is "it is a domain - use the following user and password"

Anthony Horne
  • 2,522
  • 2
  • 29
  • 51
  • I've red that Trusted_Connection=Yes is for ODBC and Integrated Security=SSPI is for OLE... But it's not working anyway – Gabriel Matusevich May 26 '14 at 06:10
  • If you plan on using a user and password, then you will need to change your SQL installation to Mixed Mode (from NT Auth). See: http://blog.sqlauthority.com/2007/04/14/sql-server-fix-error-18452-login-failed-for-user-null-the-user-is-not-associated-with-a-trusted-sql-server-connection/ – Anthony Horne May 26 '14 at 06:58
  • I read wrong. Surely it should be conn = new PDO("odbc:Driver={SQL Server};Server=MyServer;Database=MyDB",Uid="sa",Pwd="pass"); instead of conn = new PDO("odbc:Driver={SQL Server};Server=MyServer;Database=MyDB","sa","pass"); – Anthony Horne May 26 '14 at 07:01
  • 1
    that is not correct. the sinyaxis is wrong. you cannot write Uid="" ... unless is inside the string – Gabriel Matusevich May 26 '14 at 19:54
  • @GabrielMatusevich Well spotted - quick-copy-paste.... I read wrong. Surely it should be conn = new PDO("odbc:Driver={SQL Server};Server=MyServer;Database=MyDB;Uid=sa;Pwd=pass"); instead of conn = new PDO("odbc:Driver={SQL Server};Server=MyServer;Database=MyDB","sa","pass"); Should be along those lines. Goto connectionstrings.org for an excellent and updated list of connection strings for all flavours. – Anthony Horne May 26 '14 at 20:17
  • doesn't recognize the Uid... if I put Trusted Connection = Yes, It says user(null) and if I put Trusted Connection = No it says the user('sa') is not recognized........... – Gabriel Matusevich Jun 03 '14 at 07:14