I cannot access database via SQL server - DSN

Asked

Viewed 117 times

1

I have a class that I can connect to Mysql, and I would like to use it to access a database on a local network and that is in SQL SERVER 2014.

private static function Conectar() {
    try {
        if (self::$Connect == null):
            $dsn = 'sqlsrv:host=' . self::$Host . ';database=' . self::$Dbsa;
            //$options = [ PDO:: PGSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8'];
            self::$Connect = new PDO($dsn, self::$User, self::$Pass); //, $options);
            self::$Connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        endif;
    } catch (PDOException $e) {
        PHPErro($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine());
        die;
    }

    return self::$Connect;
}

But I can’t connect because it gives the error of could not find driver. I already downloaded the version SQLSRV32, I threw it in the folder C: wamp64 bin php php5.6.16 ext (using wampserver64), in a notebobok with windows 10 64. Even editing the file php.ini and enabling . dll’s :

php_pdo_sqlsrv_56_nts 
php_pdo_sqlsrv_56_ts 
php_sqlsrv_56_ts 
php_sqlsrv_56_nts.

Even with all this, I couldn’t connect. How do I get this?

  • Create a test file with this content <?php&#xA;ini_set('display_errors', true);ini_set('display_errors', true);error_reporting(E_ALL|E_STRICT); see if an error appears. Any changes to php.ini don’t forget to restart apache. phpinfo();`

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.