TechnologY

Migrating database from one PC to Another

1. Detach database:

1A. Open SQL Server Management in Administrator mode

1B. Click on connect

1C. Expand Database

1D. Right click on whichever database you want to detach…say “XYZ_db”

1E. Goto Tasks-> Detach…

Now you database is ready to be copied.

Goto to the folder where your database is stored and copy both “XYZ_db.mdf” and “XYZ_db.log” file to your usb-drive

Now copy it in another PC and paste in any folder

2. Attach database:

2A. Open SQL Server Management in Administrator mode

2B. Right click Databases

2C. Click Attach and browse to the folder where you have copied your XYZ_db files

2D. Select the XYZ_db.mdf file and click “Ok”

Now your database is ready to be used.
Now you have to make changes in the website or the project in Visual Studio.

3. Now open Visual Studio and open Server Explorer or hot-key Ctrl+W, L

3A. Now expand Data Connections

3B. You will see “X” cross mark on your Data-Connection Strings you had built in some other PC…Say “XYZ_db_connectionString”

3C. Now right click on “XYZ_db_connectionString” and hit Modify Connection…

3D. Now look for the Server name: and change it to the local-server name. In my case it is SCHANDRA
Image
3E. Hit Test Connection at the bottom of the screen and you will get a message as “Test connection succeeded.” Click “Ok”

3F. Now you will have to only change the Database connection in either Web Config or wherever you have declared it.eg:
connectionString=”Data Source=SCHANDRA

and your application is good to go.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s