How can I connect Laravel 10 to a remote SQL Server 2000 using ODBC and PHP 8.1?

369 Views Asked by At

I'm working on a web project using Laravel 10, which requires me to get data from a remote SQL Server 2000. To simulate this, I installed WinXP and SQL Server 2000 on VirtualBox. I'm using Windows 10 latest build. I'm not in a position to upgrade the SQL Server to newer version, since my client's primary application depends on that one. After everything that I have tried, I still getting this error:

SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712

I'm using PHP 8.1 according to Laravel requirements

I have installed pdo_sqlsrv and sqlsrv extensions

extension=sqlsrv_81_ts_x64
extension=pdo_sqlsrv_81_ts_x64

pdo_sqlsrv in phpinfo()

sqlsrv in phpinfo()

I have already added the DSN on ODBC Data Source Administrator (XP-SP3)

Tests completed successfully

CMIIW, but according to articles that I have read, Windows 10 latest build comes preinstalled with ODBC driver Version 10, which is the only supported ODBC driver for SQL Server 2000. Hence, I did not install any newer version.

This is the database config I'm using for my Laravel project. DB_HOST and DB_PORT is correct, as I have tested the connection using ODBC Data Source Administrator

'sqlsrv' => [
            'driver' => 'sqlsrv',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
            'search_path' => 'public',
        ],

I'm expecting Laravel to be able to connect to my VirtualBox XP SQL Server 2000, and enable me to get data from the tables. At this point, even if it works, I'm not sure which step is the one to make it works.

Or should I downgrade Laravel version? Which Laravel version supports this kind of connection with the most minimum setup? Should I install another ODBC driver version, if so, which version?

Any information will be greatly appreciated.

0

There are 0 best solutions below