p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP.NET 4 : in C# and VB (http://p2p.wrox.com/forumdisplay.php?f=560)
-   -   Moving DB to App_Data Folder (http://p2p.wrox.com/showthread.php?t=81675)

demac3 November 23rd, 2010 10:36 AM

Moving DB to App_Data Folder
 
I am attempting to migrate from Access 2007 to SQL server express. I have researched how to do this and I am able to successfully do this conversion. When I open SQL Server Express my database is present as well as all the data.

When working with databases per this book, we are instructed to move the database to the App_Data folder. I cannot find my SQL Server database anywhere on my computer. It appears to be accessible by SQL Server express, but hidden for other uses. How do I get around this problem?

Imar November 23rd, 2010 12:36 PM

Hi there,

You have at least two alternatives:

1) use the database attached to SQL Server Express. For information about changing your connection string, check out Appendix B

2) Detach the database and then move it to App_Data and update your connection string. To see where the physical files are located before detaching, open the properties dialog for your database in SQL Server Management Studio and look in the File category. In the Path column you see the folder where the file are stored. Then close that dialog, right-click your database and choose Tasks | Detach.

Hope this helps,

Imar

demac3 November 23rd, 2010 02:35 PM

Thank you! That worked perfectly - I used the detach concept.

chroniclemaster1 November 24th, 2010 07:11 PM

Scenario one is usually the best choice in production. It's better to have a quality database server managing your databases and simply use a connection string to have your application on the server connect to the DB on the DB server. However, this is usually a more expensive option in hosting and you don't always have that option. Even if you do, you'll need to be able to upload and download data between your local instance of SQL Server Express and the production database or the two will quickly get out of synchronization, and that's usually a more difficult development scenario than putting together a synchronization procedure.

If you don't have that option, scenario two is the easier and cheaper scenario although it means one server will be managing both the application and the database which is difficult if you need the performance. However, the .mdf file, once in your App_Data folder is easy to copy up and down from the server like any other file making synchronization a snap, and you can set the connection string to work off the database directly from the App_Code folder which makes development and production simple to manage.


All times are GMT -4. The time now is 01:19 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.