KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

MSSQL Driver not found #2516

Closed Report Lab opened this topic on on Jan 2, 2022 - 14 comments

Report Lab commented on Jan 2, 2022

Good day

Can someone please assist or give me guidance on the following error?

"Message: could not find driver"

I have already added the correct dll's in the php/ext folder and included them in the php.ini file, and when I run a composer update or reinstall, I have no errors.

I've created a class that mimics the AutoMaker class as per the below:

use koolreport\dashboard\sources\SQLServer;

class MSDB extends SQLServer
{
    protected function connection()
    {
        return [
            "connectionString"=>"Sqlsrv:Server=localhost;dbname=Development",
            "username"=>"username",
            "password"=>"password",
            "charset"=>"utf8"
        ];
    }
}

I then use the class as per the below:

class ReportName extends Table
{

    protected function dataSource()
    {
        return MSDB::table("users")
            ->select("*");
    }

    protected function fields(){
        return[
            Text::create("username"),
            Number::create("id")
        ];

    }
}

Any assistance will be appreciated.

Sebastian Morales commented on Jan 4, 2022

There are many types of mssql php driver (thread safe vs non thread safe, x64 vs x86). If I recall correctly, the correct driver should be non thread safe (nts) x86 (since PHP on Windows 64 bit is still 32 bit app, if you use Linux it could be a different driver). Pls post your mssql php driver dll file name. You can also check your web server's (e.g Apache, Nginx) log to see if the driver is loaded correctly. Rgds,

Report Lab commented on Jan 4, 2022

I appreciate your response.

The drivers I'm using are as follow:

Sebastian Morales commented on Jan 4, 2022

Pls try the nts_x86.dll extensions. Even if your Windows is 64 bit. its PHP implementation could still be 32 bit. Tks,

Report Lab commented on Jan 4, 2022

I still get the same error after changing to the 32-bit drivers.

I do, however, get the following when running a Composer update:

PHP Warning: PHP Startup: Unable to load dynamic library 'php_pdo_sqlsrv_80_nts_x86.dll' (tried: C:\php\ext\php_pdo_sqlsrv_80_nts_x86.dll (%1 is not a valid Win32 application), C:\php\ext\php_php_pdo_sqlsrv_80_nts_x86.dll.dll (The specified module could not be found)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'php_pdo_sqlsrv_80_nts_x86.dll' (tried: C:\php\ext\php_pdo_sqlsrv_80_nts_x86.dll (%1 is not a valid Win32 application), C:\php\ext\php_php_pdo_sqlsrv_80_nts_x86.dll.dll (The specified module could not be found)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'php_sqlsrv_80_nts_x86.dll' (tried: C:\php\ext\php_sqlsrv_80_nts_x86.dll (%1 is not a valid Win32 application), C:\php\ext\php_php_sqlsrv_80_nts_x86.dll.dll (The specified module could not be found)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'php_sqlsrv_80_nts_x86.dll' (tried: C:\php\ext\php_sqlsrv_80_nts_x86.dll (%1 is not a valid Win32 application), C:\php\ext\php_php_sqlsrv_80_nts_x86.dll.dll (The specified module could not be found)) in Unknown on line 0 PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'php8.dll' in Unknown on line 0

I, therefore, believe I had the correct drivers and I am not sure why they are not found.

Sebastian Morales commented on Jan 4, 2022

Ok, let's try with your previous x64 driver and use the following connection string:

            "connectionString"=>"sqlsrv:Server=localhost;dbname=Development", // change "Sqlsrv" to "sqlsrv" as some drivers' connection string is case sensitive
Report Lab commented on Jan 4, 2022

Hi Sebastian

That did not work either.

Sebastian Morales commented on Jan 4, 2022

What did your web server's log say when you restart it with your driver?

Report Lab commented on Jan 4, 2022

From what I can see, the logs are clean.

Is there somewhere specific you would like me to check?

Sebastian Morales commented on Jan 5, 2022

Ok, let's try this connection string:

            "connectionString"=>"sqlsrv:Server=localhost;Database=Development", // use Database instead of dbname
Report Lab commented on Jan 5, 2022

I'm still receiving the following:

Message: could not find driver Line: 121 File: /mnt/c/Project/vendor/koolreport/core/src/datasources/PdoDataSource.php Collapse #0: /mnt/c/Project/vendor/koolreport/core/src/datasources/PdoDataSource.php Line 121 : construct(null) #1: /mnt/c/Project/vendor/koolreport/core/src/core/DataSource.php Line 57 : onInit(null) #2: /mnt/c/Project/vendor/koolreport/dashboard/sources/PDOSource.php Line 128 : construct(null) #3: /mnt/c/Project/vendor/koolreport/dashboard/data/SQLHandler.php Line 69 : run(null) #4: /mnt/c/Project/vendor/koolreport/dashboard/widgets/Table.php Line 223 : executes(null) #5: /mnt/c/Project/vendor/koolreport/dashboard/widgets/Table.php Line 253 : dataView(null) #6: /mnt/c/Project/vendor/koolreport/dashboard/Widget.php Line 223 : render(null) #7: /mnt/c/Project/vendor/koolreport/dashboard/theme/TRenderItem.php Line 16 : view(null) #8: /mnt/c/Project/vendor/koolreport/dashboard/amazing/containers/Panel.view.php Line 56 : renderItem(null) #9: /mnt/c/Project/vendor/koolreport/core/src/KoolReport.php Line 502 : include(["/mnt/c/Project/vendor/koolreport/dashboard/amazing/containers/Panel.view.php"]) #10: /mnt/c/Project/vendor/koolreport/dashboard/theme/TRender.php Line 10 : render(null) #11: /mnt/c/Project/vendor/koolreport/dashboard/containers/Panel.php Line 132 : render(null) #12: /mnt/c/Project/vendor/koolreport/dashboard/containers/Container.php Line 120 : render(null) #13: /mnt/c/Project/vendor/koolreport/dashboard/theme/TRenderItem.php Line 18 : view(null) #14: /mnt/c/Project/vendor/koolreport/dashboard/amazing/Dashboard.view.php Line 10 : renderItem(null) #15: /mnt/c/Project/vendor/koolreport/core/src/KoolReport.php Line 502 : include(["/mnt/c/Project/vendor/koolreport/dashboard/amazing/Dashboard.view.php"]) #16: /mnt/c/Project/vendor/koolreport/dashboard/theme/TRender.php Line 12 : render(null) #17: /mnt/c/Project/vendor/koolreport/dashboard/Dashboard.php Line 367 : render(null) #18: /mnt/c/Project/vendor/koolreport/dashboard/Dashboard.php Line 337 : render(null) #19: /mnt/c/Project/vendor/koolreport/dashboard/Dashboard.php Line 317 : view(null) #20: /mnt/c/Project/vendor/koolreport/dashboard/TAction.php Line 37 : actionIndex(null) #21: /mnt/c/Project/vendor/koolreport/dashboard/Dashboard.php Line 275 : action(null) #22: /mnt/c/Project/vendor/koolreport/dashboard/pages/Main.php Line 137 : handle(null) #23: /mnt/c/Project/vendor/koolreport/dashboard/Application.php Line 217 : handle(null) #24: /mnt/c/Project/vendor/koolreport/dashboard/Application.php Line 149 : handle(null) #25: /mnt/c/Project/index.php Line 9 : run(null)

Sebastian Morales commented on Jan 6, 2022

Ok, pls add both the thread safe (ts_x64) drivers and non thread safe (nts_x64) ones to your php/ext directory and php.ini. Then restart your web server and use the "connectionString" I provided. If it doesn't work, remove the non thread safe drivers and try again. Let us know the result. Tks,

Report Lab commented on Jan 6, 2022

Hi Sabastian

Still no luck. As soon as I add the thread safe drivers, composer throws the following error:

PHP Warning: PHP Startup: Unable to load dynamic library 'php_pdo_sqlsrv_80_ts_x64.dll' (tried: C:\php\ext\php_pdo_sqlsrv_80_ts_x64.dll (The specified module could not be found), C:\php\ext\php_php_pdo_sqlsrv_80_ts_x64.dll.dll (The specified module could not be found)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'php_pdo_sqlsrv_80_ts_x64.dll' (tried: C:\php\ext\php_pdo_sqlsrv_80_ts_x64.dll (The specified module could not be found), C:\php\ext\php_php_pdo_sqlsrv_80_ts_x64.dll.dll (The specified module could not be found)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'php_sqlsrv_80_ts_x64.dll' (tried: C:\php\ext\php_sqlsrv_80_ts_x64.dll (The specified module could not be found), C:\php\ext\php_php_sqlsrv_80_ts_x64.dll.dll (The specified module could not be found)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'php_sqlsrv_80_ts_x64.dll' (tried: C:\php\ext\php_sqlsrv_80_ts_x64.dll (The specified module could not be found), C:\php\ext\php_php_sqlsrv_80_ts_x64.dll.dll (The specified module could not be found)) in Unknown on line 0

Sebastian Morales commented on Jan 6, 2022

Sorry, but I don't understand why composer, which manages PHP packages, not drivers, gave warning about a PHP extension. Shouldn't your web server be the one to load PHP extensions and give warning if there is.

Anyway, despite the warning just try KoolReport with the thread safe drivers enabled again and let us know of any error message. Tks,

Report Lab commented on Jan 7, 2022

I agree, but if I change the drivers to point at the TS drivers as you suggested above, Composer raises these errors and I still do not see any errors raised in the Apache log.

I did, however, figure it out. I had two installations of php.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Dashboard