In the unfortunate event that your database becomes corrupted, check your event log in the first instance. If you receive an error as follows:
FCB::Open Failed: Could not open file .mdf for file number 1. OS error: 5(failed to retrieve text for this error. Reason: 15100).
You will need to detach and attach the database. If you are unable to do this then the following method will work, but you will stand a chance of losing all your data. So be very careful and think before you act.
In Configuration Manager stop the SQL Server. Move the MDF and LDF to a different location. Open SQL Server Management Studio as Administrator and delete the database. Move the MDF and LDF back to the same location. In SQL Server Management Studio, attach the database. You should now be up and running.
Hopefully, all your data should be there. If you have lost your data, perform a database repair from a backup. Remember, it is a good practice to perform nightly backups of a SQL Server. In my experience providing customer support for our products at the company where I work, it is surprising how many establishments do not perform server backups at all! When I encounter this situation, I always advise them on performing regular server backups, and from within our software regularly saving archives in case they ever need to recover a damaged database or lost data.