Tried this in as connection string
connectionString=\"Server=.\\SQLEXPRESS;
AttachDbFilename=E:\\Database\\dnn49.mdf;Database=dnn49;
Trusted_Connect
If you're attaching from SQL Server Management Studio, it also works to run SSMS as an administrator. This then can take advantage of the fact that the Administrators group has full control over the file. Another much more rare circumstance is that you'll get this Access Denied error because the database is already attached. This is probably more obvious unless you have multiple instances of SQL Server running and you already attached it to another instance possibly.