1

So I am using Laravel with a Microsoft Database and a MYSQL Database. The MYSQL connect just fine and displays results, but the Microsoft database returns a SQLSTATE[08001] error.

local.ERROR: SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746 (SQL: select top 1 * from [UserSummary] where [UserSummary].[UserID] = 233305

I can get the same statement to run fine in another project but in our current project it always gives us this error.

I tried downgrading Laravel to match the other project and that did not work.

Here is our config for sqlsrv

'sqlsrv' => [
            'driver' => 'sqlsrv',
            'host' => env('MICROSOFT_DB_HOST'),
            'port' => env('MICROSOFT_DB_PORT'),
            'database' => env('MICROSOFT_DB_DATABASE'),
            'username' => env('MICROSOFT_DB_USERNAME'),
            'password' => env('MICROSOFT_DB_PASSWORD'),
            'charset' => 'utf8',
            'prefix' => '',
        ],

I could be wrong but it seems like we are connecting its just that the statement is not running. With the same credentials I can connect to DataGrip and view the data in the DB.

I am unsure how to fix this error?

Dale K
  • 25,246
  • 15
  • 42
  • 71
John
  • 31
  • 1
  • 5
  • 1
    This is a case where knowing what version your sql server is would be helpful. My first recommendation is to check the TLS 1.2 version support of your current SQL Server version. [This page](https://support.microsoft.com/en-us/help/3135244/tls-1-2-support-for-microsoft-sql-server) should help. – Laughing Vergil Aug 06 '19 at 21:37
  • This answer may simplify everything you need to do: https://stackoverflow.com/a/61111267/9535070 – ofundefined Apr 08 '20 at 22:56

1 Answers1

0

You are not connecting. The actual error code is:

Error code 0x2746. Client unable to establish connection.

Are you able to use sqlcmd -S <myserver> -d <mydatabase> -U <myusername> -P <mypassword> to connect to the instance?

If so, there's something wrong with your Laravel config. If not, there's something wrong with your SQL config (Docker compose? Firewall configs?)

AlwaysLearning
  • 7,915
  • 5
  • 27
  • 35