我的連接如字符串是設置方式對數據源的連接字符串
string connStr = @"Data Source=(local)\SQLEXPRESS
Initial Catalog=University11;
Integrated Security=True";
但後來我複製我的數據庫
C:\Users\Чак\Desktop\ботанизм\ООП\coursework.start\CourseWorkFinal\CourseWorkFinal\
,並設置爲在連接字符串的方式
string connStr = @"Data Source=C:\Users\Чак\Desktop\ботанизм\ООП\coursework.start\CourseWorkFinal\CourseWorkFinal\;
Initial Catalog=University11;
Integrated Security=True";
但在這種情況下,我有一個例外
A network-related or instance-specific error occurred while establishing a connection
to SQL Server. The server was not found or was not accessible. Verify that the instance
name is correct and that SQL Server is configured to allow remote connections.
(provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)
我需要什麼正確的連接字符串?
當你說你複製了你的數據庫,是從Management Studio內部獲得的,還是你複製了MDF/LDF文件? –
只需複製mdf&ldf文件 –
您確實應該使用SSMS將這些文件附加到SQL Express。然後連接到。\ SQLEXPRESS並指定一個初始目錄應該可以工作。 – RickNZ