Sodding MS removed stored credentials from ODBC connections, so you have to use trusted connections, which opens a whole other slew of issues.

Use Peter's code above, or mine.