PDO_SQLSRV DSNConnecting to MS SQL Server and SQL Azure databases DescriptionThe PDO_SQLSRV Data Source Name (DSN) is composed of the following elements:
Examples
Example #1 PDO_SQLSRV DSN examples The following example shows how to connecto to a specified MS SQL Server database: $c = new PDO("sqlsrv:Server=localhost;Database=testdb", "UserName", "Password"); The following example shows how to connect to a MS SQL Server database on a specified port: $c = new PDO("sqlsrv:Server=localhost,1521;Database=testdb", "UserName", "Password"); The following example shows how to connecto to a SQL Azure database with server ID 12345abcde. Note that when you connect to SQL Azure with PDO, your username will be UserName@12345abcde (UserName@ServerId). $c = new PDO("sqlsrv:Server=12345abcde.database.windows.net;Database=testdb", "UserName@12345abcde", "Password"); |