I am trying to connect to SQL Server 2008 (not express) with PHP 5.2.9-2 on Windows XP sp2. I can connect to the remote SQL Server fine from SQL Server Management Studio from the same machine. 

My first attempt was this:

```
$conn = new PDO("mssql:host={$host};dbname={$db}", $user, $pass);

```

Which gives this error:

```

PHP Fatal error:  
Uncaught exception 'PDOException' with message 
'SQLSTATE[0100] Unable to connect: SQL Server is unavailable or does not exist.  
Access denied. (severity 9)'
```

Second attempt (found on [experts-exchange](http://www.google.co.uk/search?q=Q_23833867%20experts%20exchange))

```
$conn = new PDO("odbc:Driver={SQL Server Native Client 10.0};Server={$host};Database={$db};Uid={$user};Pwd={$pass}", 
                         $user, $pass);

```

This works, but I can't use `PDO::lastInsertId()`, which I would like to be able to:

```
 Driver does not support this function: driver does not support lastInsertId()
```

Do you have any suggestions? Any help would be greatly appreciated.