Hi,
If you want to access your database file (.mdf) from CD or Pen Drive, you have yo attach your database with Sql server first.
To know how to attach database use link
Attach database
once your database is attached with Sql server, then you can easily access it using connection string.