Search code examples
sqlvb.netprojectmdf

use sql server .mdf file


I am developing a software with vb.net 2010 and sql server 2008 R2. While developing with my laptop where sql server is running every thing is ok, but when I want to deliver the project to the customer I must install sql server R2 to customer machine. How to get my database .mdf format to use it with my project. Thankyou


Solution

  • You need to detach the mdf file from your computer and then copy that file to your storage device of your choice say a USB. Afterwards if there is already an installed SQL server in your client you could copy the mdf file that you detach and then attach that mdf file this time.

    To Detach:

    • Right Click on the Database that you want to Detach then Task --> Detach

    enter image description here

    To Attach:

    • Right Click on the word Databases then Attach

    enter image description here

    Don't forget of course to Attach again in your own computer the Database that you detached earlier.