I want to connect SQL Server database which is in

2019-08-12 04:38发布

问题:

I have created an ASP.Net web application with SQL Server 2005 database on another computer.

I want to transfer it to another PC. Therefore, I have copied the ASP.Net Project and also the SQL database in .bak format. I need to configure the application to connect to the database and need help to get the correct connection string.

PS: the database created was by SQL Server 2005 and I need to deploy on SQL Server 2012

回答1:

bak files are Sql Server backup files. You need to restore it into the Sql Server 2012 and go from there.

Restoring database files in Sql Server 2012 -> http://msdn.microsoft.com/en-us/library/ms177429.aspx

And the connection string to connect you application to it -> http://connectionstrings.com/sql-server-2012



回答2:

You have to restore the database on new sql server 2012, then you can make a new connection string. If you leave the name the same, you only have to change the name of the server in the connection string.



回答3:

Links by "tucaz" are good examples to start with. You can also follow these steps to get an idea.

  1. Create new database on SQL server 2012 on new PC

  2. Right click newly created database and find Restore database option. Give .bak files needed to restore

  3. Make sure to select "Overwrite the existing database (WITH REPLACE)" option in restore database file window

  4. Once the backup is restored, the use the following format of the connection string on application config file.

    <add name="connectionstring" 
         connectionString="Data Source=ServerName;Initial catalog=DBName;user id=UserName;password=password;Language=British;" />