I have laravel 7.3, and sql server 16,
i need to connect to the database sql server, but i have this error :
SQLSTATE = 08001 error- No connection could be made because the target machine actively refused it.
and there is the .env file
DB_CONNECTION=sqlsrv
DB_HOST=127.0.0.1/instancename
DB_PORT=1433
DB_DATABASE=Database
DB_USERNAME=sa
DB_PASSWORD=12345678`
But when i use the simple php file to connect the connexion is ok.
this is the php script :
<?php
$serverName = "127.0.0.1/instancename";
$connectionInfo = array( "Database"=>"Database", "UID"=>"sa", "PWD"=>"12345678");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connexion établie.<br />";
}else{
echo "La connexion n'a pu être établie.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>
Manny thanks for your help
1条答案
按热度按时间5vf7fwbs1#
You can use this method Firstly add your sql server configuration in
config/database.php
Then Add Model connection as