无法将文件附加为数据库

时间:2018-10-30 09:39:07

标签: c# database localdb

我已经看过所有其他帖子,似乎帮不了我。

String constr = (@"Data Source=(localdb)\MSSQLLocalDB;
        AttachDbFilename= E:\Downloads Mainframe\Compressed\Main Menu\HRDAssets.mdf;
        initial catalog=HRDAssets; 
        Integrated Security=True;");

https://cdn.discordapp.com/attachments/268002637905920001/506753130848059394/unknown.png

当我删除

AttachDbFilename= E:\Downloads Mainframe\Compressed\Main Menu\HRDAssets.mdf;

出现新问题

https://cdn.discordapp.com/attachments/506763196225421312/506763211492556800/unknown.png

1 个答案:

答案 0 :(得分:0)

从连接字符串中删除此行

AttachDbFilename= E:\Downloads Mainframe\Compressed\Main Menu\HRDAssets.mdf;

初始目录属性,我建议使用:

Data Source=(LocalDb)\MSSQLLocalDB;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\HRDAssets.mdf