I'm trying to connect to a SQL server database using larval but when I tried to test I keep getting this error I tried many many solutions.
SQLSTATE[28000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Failed to log on user 'slim'. (SQL: SELECT * FROM names) (View: C:\xampp\htdocs\laravel\pointeur\resources\views\welcome.blade.php)
I've created a simple Model :
namespace App; use Illuminate\Database\Eloquent\Model; class Record extends Model { protected $table = 'names'; }with a simple query
$records = Record::all(); foreach ($records as $record) { echo $record->name; } ?>database.php
'sqlsrv' => [ 'driver' => 'sqlsrv', 'host' => env('DB_HOST', 'DESKTOP-ILM6T0L\SQLEXPRESS1'), 'database' => env('DB_DATABASE', 'a11'), 'username' => env('DB_USERNAME', 'ismail'), 'password' => env('DB_PASSWORD', 'root'), 'charset' => 'utf8', 'prefix' => '', ],.env file
DB_CONNECTION=sqlsrv DB_HOST=DESKTOP-ILM6T0L\ISMAIL DB_PORT=3306 DB_DATABASE=a11 DB_USERNAME=slim DB_PASSWORD=root
(I created a user 'slim' with password 'root' )
Db name a11 it has 1 table 'names' with 1 column 'names'.
Help please I just want to connect laravel project with sql server :p
slim, did you specify the correct host to go with that user? Generally for development, it's okay to use%as the host which would allow the userslimto connect from anywhere.