How to connect to a Microsoft SQL Database

Abstract: How to connect to a Microsoft SQL Database

    Microsoft SQL Server

To connect to Microsoft SQL Server, the first thing you must do is to setup PHP to access MS SQL Server, to do it:

  • Modify php.ini.template if you are inside the IDE or php.ini if you are in a host, you will need to uncomment/add this line:
extension=php_mssql.dll

Note: If you are inside the IDE, it's safer you close the IDE and open again for changes to take effect

For more information on how to get PHP connect SQL Server, checkout this link:

SQL Server Functions

  • Use a Database component by setting:

-DatabaseName: Name of the database you want to connect

-DriverName: mssql

-Host: localhost or localhost,1433 or if you are using SQL Server Express 2005 hostname\instance for example QLAPTOP\SQLEXPRESS

-Username: Name of the user with access, i.e.: sa

-UserPassword: Password for that user


    SQL Server Express 2005

If you are connecting to SQL Server Express 2005, and you can not connect, probably you will need to change your ntwdblib.dll to another version to make PHP work with it, in our tests, we had to update it to one we found here:

Webzilla

Search for ntwdblib.dll and pickup the 2000.80.194.0, 274Kb