如何使用2012年使用SQL Server創建的數據庫文件(.mdf
)從Visual Studio調用它(作爲實例)?如何將SQL Server 2012 .mdf文件升級到SQL Server 2014?
SqlConnection con = new SqlConnection("Data Source = .\\SQLEXPRESS; Initial Catalog = DB; Integrated Security = False; User ID = hi; Password=123");
這是代碼來調用它,但僅適用於SQL Server 2012的如何在SQL Server 2014使用它呢?我一直在得到這個錯誤:
This database file is not compatible with the current instance of SQL Server.
To resolve this issue, you must upgrade the database file by creating a new data connection, or you must modify the existing connection to this database file.
數據庫不是*文件*。你不能只從一臺服務器上獲取'mdf'文件並在另一臺服務器上打開它。從舊服務器上分離數據庫並將其附加到新服務器上。分離可確保在數據庫脫機之前完成所有現有事務。附加照顧任何必要的升級步驟。 –
@PanagiotisKanavos我已經把它放到了我的sql server managament 2014中,它讀取它,現在我唯一的問題是我將如何在Visual Studio中調用它?它的恰當實例是什麼? –
在您的sql server 2014實例中,運行以下腳本:CREATE DATABASE DB ON (FILENAME ='PATH_TO_YOUR_MDF_FILE') FOR ATTACH' – Hackerman