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(); }