Is your site properly defined for dynamic development.
In the Site definition, there must e a connection to the testing server set up, the testing server connection is used when making the database connection, if not properly set, the connection will fail.
see the "Defining a Dynamic Site in Dreamweaver" tutorial on the learning center page for details:
tutorials.php