KoolReport's Forum

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

Uncaught PDOException: could not find driver #1965

Open Gabriela Matheus opened this topic on on Mar 11, 2021 - 8 comments

Gabriela Matheus commented on Mar 11, 2021

Hello, I have this error even downloading the PDO and SQL Server extensions. I already added the DLLS in PHP.INI and even then the error continues. I thank the attention. My report.php :

 protected function settings(){
        
            return array(
                "dataSources"=>array(
                    "sales"=>array(
                        "connectionString"=>"sqlsvr:server=host;dbname=dbname",
                        "username"=>"username",
                        "password"=>"password",
                        "charset"=>"utf8"
                    )
                )
            );
        
    }

My extensions added in php.ini:

extension=php_pdo_sqlsrv_80_ts_x64 extension=php_sqlsrv_80_ts_x64

Sebastian Morales commented on Mar 12, 2021

Gabriela, pls try "php_pdo_sqlsrv_80_nts_x64" in php.ini and copy the file "php_pdo_sqlsrv_80_nts_x64.dll" to the extensions directory instead. Let us know if it works for you. Rgds,

Gabriela Matheus commented on Mar 12, 2021

thanks for listening! but now I get the following error:

Uncaught Error: Call to undefined function koolreport \ datasources \ sqlsrv_connect ()

I'm passing the correct connection data because I already tested the connection, but still give me this error.

Does it have anything to do with placing the following code inside the class?:

use \koolreport\datasources\SQLSRVDataSource;
KoolReport commented on Mar 12, 2021

You do not need to add the "class"=>"\koolreport\datasources\SQLSRVDataSource" if you want to use PDO connection. Try to remove and see if it works.

Gabriela Matheus commented on Mar 12, 2021

Sorry if I did not interpret your answer correctly, but now this error appears:

Fatal error: Uncaught PDOException: PDO::__construct(): Argument #1 ($dsn) must be a valid data source name in C:\xampp\htdocs\testeComAjuda\vendor\koolreport\core\src\datasources\PdoDataSource.php:114

My report.php file:

<?php

require_once "./vendor/autoload.php";

use \koolreport\KoolReport;
use \koolreport\processes\Filter;
use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;
use \koolreport\processes\Limit;

class SakilaRental extends KoolReport
{


function settings()
{
    return array(
        "dataSources"=>array(
            "sakila"=>array(
                'datahost' => 'datahost ',
                'username' => 'username',
                'password' => 'password',
                'database' => 'database',
                'charset' => 'utf8',  
              
                'returnDatesAsStrings'=>true  
            ),
        )
    ); 
}    
    protected function setup()
    {
        $this->src('sakila')
        ->query("SELECT ANOMES,VALOR_META FROM METAS")
        ->pipe(new TimeBucket(array(
            "ANOMES"=>"month"
        )))
        ->pipe(new Group(array(
            "by"=>"ANOMES",
            "sum"=>"VALOR_META"
        )))
        ->pipe($this->dataStore('sale_by_month'));
    } 
}

Thank you so much for your patience!

Sebastian Morales commented on Mar 15, 2021

Gabriela, in case of using pdo with SQL SErver, pls use a similar setting like this:

    'pdoSqlsrv' => [
        'connectionString' => 'sqlsrv:Server=localhost;Database=automaker',
        'username' => 'sa',
        'password' => ''
    ],

There must be a connection string to specify which type of database you are using. Tks,

Gabriela Matheus commented on Mar 15, 2021

Good Morning! Thanks Sebastian for your help! But now I have this error:

Uncaught PDOException: PDO::__construct(): Argument #1 ($dsn) must be a valid data source name in C:\xampp\htdocs\testeComAjuda\vendor\koolreport\core\src\datasources\PdoDataSource.php:114 Stack trace: #0 C:\xampp\htdocs\testeComAjuda\vendor\koolreport\core\src\datasources\PdoDataSource.php(114): PDO->__construct('', '', '', NULL) #1 C:\xampp\htdocs\testeComAjuda\vendor\koolreport\core\src\core\DataSource.php(57): koolreport\datasources\PdoDataSource->onInit() #2 C:\xampp\htdocs\testeComAjuda\vendor\koolreport\core\src\KoolReport.php(264): koolreport\core\DataSource->__construct(Array, Object(SakilaRental)) #3 C:\xampp\htdocs\testeComAjuda\report.php(51): koolreport\KoolReport->src('sales') #4 C:\xampp\htdocs\testeComAjuda\vendor\koolreport\core\src\KoolReport.php(100): SakilaRental->setup() #5 C:\xampp\htdocs\testeComAjuda\index.php(8): koolreport\KoolReport->__construct() #6 {main} thrown in C:\xampp\htdocs\testeComAjuda\vendor\koolreport\core\src\datasources\PdoDataSource.php on line 114

Did I download the wrong driver? This error stuck to my project haha

Mysettings on report:

protected function settings(){
        
    return array(
        "dataSources"=>array(
            "sales"=>array(
                'pdoSqlsrv' => [
                    'connectionString' => 'sqlsrv:Server=host;Database=Database',
                    'username' => 'username',
                    'password' => 'password'
                ],
            )
        )
    );

}

Thanks for the patience!

Gabriela Matheus commented on Mar 15, 2021

Hi again! I got it! I think I was connecting wrong, so I used Sebastian's model, with some changes and it worked! Thank you for your help!

Gabriela Matheus commented on Mar 15, 2021

My settings, in case someone goes through the same problem:

protected function settings(){
        
    return array(
        "dataSources"=>array(
            "sales"=>array(
                "connectionString"=>"sqlsrv:server=host;Database=Database",
                "username"=>"username",
                "password"=>"password"
            )
        )
    );

}

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
solved

None