Sqlstate[01002] Adaptive Server Connection Failed (severity 9)
I have the following script to connect to my microsoft azure server.
Solution 1:
After some further googling I came across this answer.
Connect PHP to MSSQL via PDO ODBC
Turned out I just needed to update my /etc/freetds/freetds.conf
My changes:
Uncommented TDS protocol version and updated.
tdsversion=8.0Added mssql below examples.
[mssql]
host =
Port = 1433
tds version = 8.0
Solution 2:
I got the same issue here, but it is fixed by adding version of FreeTDS 8.0 to the connection directly in PHP code:
<?phptry {
$hostname = "secrets.database.windows.net";
$dbname = "secrets";
$username = "secrets";
$pw = "secrets";
$dbh = new PDO ("dblib:version=8.0;charset=UTF-8;host={$hostname};dbname={$dbname}", $username, $pwd);
} catch (PDOException $e) {
echo"Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}
echo"Passed!";
Solution 3:
In my case I had a typo in $dbname, correcting it solved the issue.
Solution 4:
In my case the user's password had been reset without my knowledge.
Solution 5:
In my case it was because the whl package you install when you launch "pip install pymssql" onboards the freetds 1.00.97. Rebuilding the package from source with freetds 1.1.6 installed did the trick and permit me to connect to the server.
Post a Comment for "Sqlstate[01002] Adaptive Server Connection Failed (severity 9)"