简体   繁体   中英

ASP.NET + Sql Server - How to move hosted database to same server as website?

I'm working on an asp.net website and I ran into a problem migrating the database from the original server.

Originally the database was hosted on a different server than the website is. Performance tests revealed that this is a major bottleneck so I decided to migrate the database on the same server as the website (I'm not the original designer or implementer for this website).

I've managed to obtain a dump of the database from the original server and install it on the server I'm currently using.

After migrating and connecting the database the strangest thing happened: The website features user profiles. However, with the migrated database, no matter how many users are connected they all see the information for one of them (usually the one with the greater ID number, although this is irrelevant). Moreover, the login does not work from incognito mode (Chrome) anymore. The rest of the database communication (data that is common for all users) seems to be working well.

Solutions I've tried:

  • Checking the databases for things that might have been missed while copying (foreign keys and such): they are identical, verified by hand and using special tools (SQL Compare and Data Compare), a lot of times
  • Importing the original login and permissions from the original database.
  • The website communicates with the database using a dll that handles data conversions and stored procedures calls. This .dll contained some inline sql queries which I moved in the database as stored procedures - the problem remained.

What I'm thinking now is to connect to the database via TCP/IP using the ip of the server and a designated port. I tried to to this but I was not able until now to enable remote connections to the database. Also I'm not sure that this is a good solution.

I'm using on my server:

  • Windows Server 2008 R2
  • SQL Server Enterprise 2012
  • I don't know what SQL Server version was used for the original database (as I said earlier it was not developed by me)
  • The website is written in asp.net with c# codebehind.

Do you have any idea about what could be wrong?

As mentioned in the comments, compatibility could be the issue but it may not be. Try this to back it up.

USE yourDatabaseName;
GO
BACKUP DATABASE yourDatabaseName
TO DISK = 'C:\folderName\BackUpTestServer.Bak'
   WITH FORMAT,
      MEDIANAME = 'C_SQLServerBackups',
      NAME = 'Full Backup of yourDatabaseName';
GO

Copy the file to the 2012 server. Then on the 2012 server run these steps...

1)Right Click on "Databases" in Object Explorer.

2)Click Restore Database

3)Select Device and click the "..." box

4)Select backup devices will appear, file should already be high lighted in the drop down, click "Add"

5)Find your backup file from the 2008 folder and click "OK"

6)Click Okay again and then Okay again. It should say that the database was successfully restored.

Try those steps.. this is how I have migrated my databases to new servers and how I restore databases if a server goes down due to whatever.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM