Hey there, Awesome Customers!

Just a heads up: We'll be taking a breather to celebrate International Workers' Day (May 1st and 2nd - Wednesday and Thursday) and Orthodox Easter from Good Friday (May 3rd) through Easter Monday (May 6th). So, from May 1st to May 6th, our team will be off enjoying some well-deserved downtime.

During this time, our customer support will be running on a smaller crew, but don't worry! We'll still be around to help with any urgent matters, though it might take us a bit longer than usual to get back to you.

We'll be back in action at full throttle on May 7th (Tuesday), ready to tackle your questions and requests with gusto!

In the meantime, you can explore our documentation for Amelia and wpDataTables. You'll find loads of helpful resources, including articles and handy video tutorials on YouTube (Amelia's YouTube Channel and wpDataTables' YouTube Channel). These gems might just have the answers you're looking for while we're kicking back.

Thanks a bunch for your understanding and support!

Catch you on the flip side!

Warm regards,

TMS

Okay
  Public Ticket #3593724
Connect to SQL Server
Closed

Comments

  •  1
    Tymek started the conversation

    Hi,

    I have WordPress + WPdatatables on my internal intranet.
    The server is a virtual machine + Linux Ubuntu 22.04.
    The SQL server is the second virtual machine of Windows Server 2016. When I try to connect wpdatatables to the SQL database, I get the following error:
    wpDataTables could not connect to mssql server. mssql said: There was a problem with your SQL connection - could not find driver

    T.

  • Giovanni replied

    Same needs.

  •  1,692
    Miloš replied

    Hello,

    First, please check if you have the following drivers installed on your WordPress Hosting server, and activated :

    3838527468.png

    These drivers need to be installed and activated on the server where your WordPress website is. 

    After you install and activate those drivers, it should work fine.

    If you're not sure how to install the drivers, please reach out to your hosting provider ( or on a LocalHost installation, you would need to find some tutorials online on the subject how to install these drivers from the screenshot).

    The server to which wpDataTables is connecting has its own method of establishing the connection, and we're using PHPs logic of connecting to separate connections. 

    -

    Then, when you have these installed, you need to contact the support of your remote server and ask them for instructions and details what is needed to be input in order to connect,

    such as connection name, host, port, user, password, etc;

    In the end, try to Test the DB Connection in our Plugin, and see if you get any errors.

    -

    If there are errors your server returns, those are returned by the server, 

    and only displayed by wpDataTables -

     there is no additional log within wpDataTables that would distinctively show you what's behind the error.

    I hope this helps.


    Some additional useful informations to know for MSSQL type of connection specifically;

    I searched a bit more online for general MSSQL Drivers to try and determine what should be installed on your WP Hosting Server, and i found this Post from Stack Overflow, where a User posted a Screenshot of all the Drivers he had to enable.

    He specifically highlighted these two ( which i did not see you confirmed from your end so far), the "sqlsrv" and "pdo_sqlsrv".

    1187422456.png

    Can you please check again with your WordPress Hosting Provider, do they have those two Drivers installed and activated?


    If the DB is using SSL, for MySQL, you should add mysqli_set_ssl after mysqli_connect in this file:

    wp-content/plugins/wpdatatables/source/class.sql.php on line 47

    You can read more about this on stack overflow.

    For other SQL engines, you should use the PDO extension, so if it's SQL, you can take a look at this link.



    And one final advice, this is from one of our Users, who had an issue about SSL for their MSSQL Connection.

    This is what he said solved it for him :

    In the meantime I was able to solve the connection issue and bypass the SSL by modifying the connection string to SQL Server in 

    .../wpdatatables/source/class.connection.php.

    (for the SQL Server driver) and adding no encryption and trusting server certificates (TrustServerCertificate = true; Encrypt = false).

    .......

    switch ($vendor) {
                case (self::$MSSQL):
                    if (isset($driver) && $driver == 'sqlsrv') {
                        return new PDOSql($vendor, "$driver:Server=$host,$port;Database=$database; TrustServerCertificate=True; Encrypt=false", $user, $password);
                    }

    ..............

    I hope that helps.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  1
    Tymek replied

    Thanks for reply. 

    Driver installed. The plugin tries to connect to the database, but there is an error.

    wpDataTables could not connect to mssql server. mssql said: There was a problem with your SQL connection - SQLSTATE[08001]: [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted.

  •  1
    Tymek replied

    I didn't read it to the end.

    Works! Many Thanks!

    switch ($vendor) {
                case (self::$MSSQL):
                    if (isset($driver) && $driver == 'sqlsrv') {
                        return new PDOSql($vendor, "$driver:Server=$host,$port;Database=$database; TrustServerCertificate=True; Encrypt=false", $user, $password);
                    }

  •   Miloš replied privately