KoolReport's Forum

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

Sage 50/Actian Pervasive ODBC Connection #3402

Open Andrew Guattery opened this topic on on Dec 27, 2024 - 2 comments

Andrew Guattery commented on Dec 27, 2024

...Well the topic subject says it all - Is it possible to connect to Sage accounting (Pervasive/Actian DB) via ODBC? I can successfully Create an ODBC connection in MS Windows and then connect with it via php:

$dbh1 =  new PDO ("odbc:SAGE5064",$user,$pw);
$dbh2 = odbc_connect($dsn,$user,$pw); 
$result2 = odbc_exec($dbh2, $query);

However I cannot seem to create a connection in Koolreports:

    public function settings(){
        return array(
            "dataSources"=>array(
                "source1"=>array(
                    "connectionString"=>"sqlsrv:server=SQL ; Database=Mydb1",
                    "username"=>"xxxxxxx",
                    "password"=>"xxxxxx",
                    "charset"=>"utf8"
                ),
                "source2"=>array(
                "connectionString"=>"odbc:server=SAGE5064 ; Database=Mydb2",
                "username"=>"xxxxxxx",
                "password"=>"xxxxxxx"
                )
            )
        );
    }

"source1" works just fine with MSSQL - "source2" throws errors as it is not a defined source. Is there a generic method for ODBC or is there a way to define a custom connection?

Sebastian Morales commented 2 days ago

We have not had an ODBC datasource class yet. Given your code, does creating a PDO connection succeed?

$dbh1 =  new PDO ("odbc:SAGE5064",$user,$pw); // does this return false or a PDO object?

If this does return a PDO connection you can still use PDODataSource class.

Andrew Guattery commented 1 day ago

Sebastian, So we added this:

$user = "Xxxxxxxxx"; 
$pw = "xxxxxxxxx";

$dbh1 =  new PDO ("odbc:SAGE5064",$user,$pw);
$this->src('sage_values')->query($sql)->saveTo($fuel)->pipe($this->dataStore('fuel'));

This works, but obviously not using the datasource class. I was looking at writing a custom datasource so Koolreport could have it, but the documentation wasn't overly-clear and then I got sidetracked lol. Would be good if we could get an ODBC class...

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

None