Microsoft SQL Server
From RadPHP XE2 Documentation
Contents |
Initial Setup
To get PHP and Microsoft SQL Server working together when you run the code from RadPHP, uncomment (remove the ; at the beginning) the following line on RadPHP php.ini.template file:
- ;extension=php_mssql.dll
Usage
Data Explorer Setup
When you set up a connection to a Microfost SQL Server database from the Data Explorer, you must fill Database Name property with the database server address and server instance name, separated by a backslash (\). For example: 127.0.0.1\SQLServer.
Database Setup
To use a Database component with Microsoft SQL Server, set it up with the information below:
- DriverName: mssql.
- Host: This should be filled with the database server address and server instance name, separated by a backslash (\). For example: 127.0.0.1\SQLServer.
Do not forget to fill also the rest of the basic information. You can leave the Host property empty, though.
Work With PHP
// Set Connection Data $database = 'database'; // Database name. $user = 'user'; // Username to access the database. $password = 'password'; // Password for the user. $server = 'server' // Microsoft SQL Server name. // Establish Connection $connection = mssql_connect($server, $user, $password); // Connection Test if (!$connection) echo 'Microsoft SQL Server could not be reached'; else echo 'Succesfully connected to Microsoft SQL Server'; // Select a Database if(mssql_select_db($database)) echo 'Succesfully selected Microsoft SQL Server Database'; else echo 'Microsoft SQL Server Database could not be selected'; // Close Connection mssql_close($connection);
Troubleshooting
- Microsoft SQL Server Express 2005
- If you are connecting to a Microsoft SQL Server Express 2005 and you can not establish a connection, it will probably be because your version of ntwdblib.dll is not letting PHP access the server, you will need a newer one. You can get it from your RadPHP installation folder, inside php subfolder (php\ntwdblib.dll). You should then place that .dll in a directory in the global path, for example: C:\Windows.
See Also
- php.net/mssql (Microsoft SQL Server PHP Documentation)
- aspfree.com/c/a/MS-SQL-Server/Using-PHP-with-MS-SQL-Server/ (Using PHP with Microsoft SQL Server)