正确编辑SQL连接字符串以使项目可移植

时间:2017-12-08 11:38:04

标签: c# sql-server

我正在做与C#基本输入输出到MDF数据库相关的家庭作业。我有这个connectionString:

private static string conString = "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Baycosinus\source\repos\Intern-Desktop\Intern-Desktop\db.mdf;Integrated Security=True";

我想这样做:

private static string conString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=\\db.mdf;Integrated Security=True";

所以我将能够将我的项目移动到任何计算机和数据库仍然可以使用。我怎样才能做到这一点? mdf文件现在位于可执行文件夹中。

感谢任何帮助!

0 个答案:

没有答案