简体   繁体   中英

PDO Driver cannot connect to sql - using xampp

I have been looking for a solution for this for hours now and I found a lot of solutions, but unfortunately none of them worked.
The error I am getting is :


Fatal error: Uncaught PDOException: could not find driver in C:\\xampp\\htdocs\\site\\includes\\database\\sqlsrv\\database.inc:124 Stack trace: #0 C:\\xampp\\htdocs\\site\\includes\\database\\sqlsrv\\database.inc(124): PDO->__construct('sqlsrv:Server=l...', 'sa', 'PWHERE...', Array) #1 C:\\xampp\\htdocs\\site\\includes\\database\\database.inc(1689): DatabaseConnection_sqlsrv->__construct(Array) #2 C:\\xampp\\htdocs\\site\\includes\\database\\database.inc(1479): Database::openConnection('xilenacc', 'default') #3 C:\\xampp\\htdocs\\site\\includes\\database\\database.inc(2350): Database::getConnection('default') #4 C:\\xampp\\htdocs\\site\\includes\\lock.inc(167): db_query('SELECT expire, ...', Array) #5 C:\\xampp\\htdocs\\site\\includes\\lock.inc(146): lock_may_be_available('schema:runtime:...') #6 C:\\xampp\\htdocs\\site\\includes\\bootstrap.inc(433): lock_acquire('schema:runtime:...') #7 C:\\xampp\\htdocs\\site\\includes\\bootstrap.inc(455): DrupalCacheArray->set(Array) #8 [internal function]: DrupalCacheArray->__destruct() #9 {main} th rown in C:\\xampp\\htdocs\\site\\includes\\database\\sqlsrv\\database.inc on line 124`

This is line 124 at database.inc:

 PDO::__construct($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);`
    <br>

  • PHP Version: 7.0.25
  • Mssql express 2016
  • Windows Server 2012
  • If I can provide further information, please let me know.

  • Downloading SQLSRV30 from microsoft website and putting the extensions in php ->
  • I double checked the information I have in settings.php - they are correct, I even tried changing my sql pw because I thought it might be causing this, but it didn't work.

Finally after hours of googling, I found a solution that actually worked even though it doesn't look so important.
The solution that worked with me is to install Microsoft Redistributable 2012. Kinda weird but worked!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM