Guys, I tried lots of things mentioned in Stackoverflow and laracasts for this issue but none worked, hence posting this in hope of getting some answer or advice. Also, most of the things provided belongs to MYSQL not for MS SQL.
I am using Windows 10 and using Laravel to connect to my Microsoft SQL Server 2012 Express edition.
I have the .erv file as following:
DB_CONNECTION=sqlsrv
DB_HOST=W1234567\SQLEXPRESS
DB_PORT=1433
DB_DATABASE=My_Database_Name
DB_USERNAME=sa
DB_PASSWORD=My_Password
The given details are correct but when I am running a simple query I am getting following error message in my Laravel Model:
(3/3) QueryException
could not find driver (SQL: SELECT COUNT(*) AS count FROM TBL_Data
WHERE ACTIVE_IND = 1
)
I have the WAMP running properly, I have added the SQLSRV file to my WAMP.
The entire thing was working fine, now I moved the code to different system there I am getting this error (Both the system has the same credentials only change is the Server name which I have changed) so the code should work properly as there are no changes done.
I tried checking the SQL Server TCP/IP port number in SQL Server Configuration Manager and changed it to 1433 still no luck.
I checked most of the answers here and they belong to PDO exception and asked people to uncomment the part extension=php_pdo_mysql.dll but in my case its SQL Server and normal wamp is working perfectly only seems to be problem with LARAVEL.
Can anyone provide the solutions for this?
Edited part below with some more info:
I checked if the credentials given are correct and if I am able to connect to db using a simple function in controller:
My Route: Route::get('/Test', 'My_Controller@Test');
My Controller:
public function Test(Request $request)
{
if(DB::connection()->getDatabaseName())
{
echo "connected successfully to database ".DB::connection()->getDatabaseName();
}
}
Output in the Chrome window: connected successfully to database My_Database_Name
As we see from above message, I am able to connect properly but still when I run the query I get the error:
(3/3) QueryException
could not find driver (SQL: SELECT * FROM TBL_Data WHERE ACTIVE_IND = 1 )
Added the phpinfo(); in the controller and tried to hit the URL and got the following info related to the PDO:
PDO support enabled
PDO drivers mysql, SQLite
SQLSRV is not enabled here is this something which is causing the issue?