Data tables with MSSQL

Data tables with MSSQL

ratkinsonratkinson Posts: 9Questions: 0Answers: 0

I am trying to connect datatables with mssql but i am having a bit of an issue. Any insights. see errors below:

call_user_func() expects parameter 1 to be a valid callback, class 'DataTables\Database\DriversqlsrvQuery' not found in "path/database" line 65

Cannot redeclare class DataTables\Database\SqlserverQuery in "path/Database/Driversqlsrv/Query.php" on line 0

Replies

  • allanallan Posts: 61,869Questions: 1Answers: 10,137 Site admin

    I think the issue is probably the type option in the config.php file. It is case sensitive and for SQL Server it should be:

    "type" => "Sqlserver",

    I suspect you have it as all lowercase at the moment.

    Allan

  • ratkinsonratkinson Posts: 9Questions: 0Answers: 0

    I made the change but now the driver is unknown

    Fatal error: Uncaught exception 'Exception' with message 'Unknown database driver type. Must be one of Mysql, Oracle, Postgres, Sqlite, sqlsrv' in path/Database/Database.php:56

  • allanallan Posts: 61,869Questions: 1Answers: 10,137 Site admin

    That's weird. This is the code that it uses to sent that error:

    $types = array( 'Mysql', 'Oracle', 'Postgres', 'Sqlite', 'Sqlserver' );
    

    It shouldn't be possible for it to output sqlsrv at that point in the code.

    Could you show me your full config.php file please?

    Allan

  • ratkinsonratkinson Posts: 9Questions: 0Answers: 0
    edited September 2016

    I am using laravel 5 and i just checked my database config and my driver for my default db is "sqlsrv". Im thinking if that might be my issue.

    see config.php below

    `<?php if (!defined('DATATABLES')) exit(); // Ensure being used in DataTables env.

    /*
    * DB connection script for Editor
    * Created by http://editor.datatables.net/generator
    */

    // Enable error reporting for debugging (remove for production)
    error_reporting(E_ALL);
    ini_set('display_errors', '1');

    /*
    * Edit the following with your database connection options
    */
    $sql_details = array(
    "type" => "Sqlserver",
    "user" => "testuser",
    "pass" => "pass123",
    "host" => "test",
    "port" => "",
    "db" => "testdatatbldb",
    "dsn" => ""
    );`

  • allanallan Posts: 61,869Questions: 1Answers: 10,137 Site admin

    Your $sql_details looks fine there.

    Do you have the sqlsrv PDO driver installed in your PHP? You can check by using a phpinfo() file and checking the PDO section.

    Allan

This discussion has been closed.