Often, sample projects contain a database file (MDF) but no log file (LDF).
In this case you need to attach the database running the following query against master in SQL Server Management Studio:
EXEC sp_attach_db @dbname = N'DBName',
@filename1 = N'D:\Working Folders\Project\App_Data\DBName.mdf'
This will not only attach the database but also create a log file.
Note: replace DBName and path as required.