PHP connect to SQL Database

function dbConnect() {

//$dsn = "sqlsrv:Server=localhost,1433;Database=AbcData;ConnectionPooling=0";
$dsn = "sqlsrv:server=(localdb)\\v11.0; AttachDBFilename=C:\MyLocalDB\AbcData.mdf; Database=AbcData";
$user = "AbcUser";
$password = "AbcPsw";
//$conn = new PDO($dsn, "AbcDev", "AbcPsw");
try {
$conn = new PDO($dsn, $user, $password);
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}

Comments

Popular posts from this blog

Error - vbe6ext.olb could not be loaded

Visual Studio $(TargetDir) macro is empty