skip to Main Content

I am facing this error at the time of configuration my laravel 6.2 project with PHP 7.2.5 to MSSQL SERVER and I have added in .env file

DB_CONNECTION=sqlsrv
DB_HOST="DESKTOP-AMCDA5K"
DB_PORT=1433
DB_DATABASE="AuditReferences"
DB_USERNAME="sa"
DB_PASSWORD="admin123"
DB_ENCRYPT=true
DB_TRUST_SERVER_CERTIFICATE=false

for view server connection page is here
server login page

and I have added all dll files in php.ini file setting and pdo_sqlsrv, sqlsrv are shown in phpinfo page

$ php artisan migrate

 IlluminateDatabaseQueryException  : could not find driver (SQL: select * from sysobjects where type in ('U', 'V') and name = migrations)
 at C:wamp64wwwLaravellaravelProjvendorlaravelframeworksrcIlluminateDatabaseConnection.php:669
665|         // If an exception occurs when attempting to run a query, we'll format the error
666|         // message to include the bindings with SQL, which will make this exception a
667|         // lot more helpful to the developer instead of just the database's errors.
668|         catch (Exception $e) {
> 669|             throw new QueryException(
670|                 $query, $this->prepareBindings($bindings), $e
671|             );
672|         }
673|

Exception trace:

1   PDOException::("could not find driver") C:wamp64wwwLaravellaravelProjvendorlaravelframeworksrcIlluminateDatabaseConnectorsConnector.php:70

2   PDO::__construct("dblib:host=DESKTOP-AMCDA5K:1433;dbname=AuditReferences;charset=utf8", "sa", "admin123", []) C:wamp64wwwLaravellaravelProjvendorlaravelframeworksrcIlluminateDatabaseConnectorsConnector.php:70

2

Answers


  1. Welcome to Stack Overflow!

    From my experience this is usually because the host in the .env file is incorrect.

    Your host of DB_HOST="DESKTOP-AMCDA5K" seems weird at first glance (I’m assuming this is your PC name).

    try using DB_HOST=localhost or DB_HOST=127.0.0.1 assuming the SQL server is located on the same machine as Laravel

    Login or Signup to reply.
  2. As mentioned in the error message, the problem lay in the SQL driver.

    SQL driver facilitates the connection between the application and the database (vice versa). Generally we two types of SQL drivers: ODBC and JDBC
    Anything went wrong with the SQL driver and/or its configuration/dependencies may result in such errors mentioned above.

    You are being requested to take a thorough examination of your local environment to find out what went wrong so far.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search