无法从c驱动器访问mdf文件,创建设置后只读正在发生。我们需要做什么 [英] Unable to access mdf file from c drive , after creating setup read only is happening.what we need to do
问题描述
string outputFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly()。Location);
          string attachDbFilename = Path.Combine(outputFolder," Database.mdf");
          return string.Format(@" Data Source =(LocalDB)\ v11.0; Initial Catalog = LocalDbDemo; AttachDbFilename ="" {0}"" ;; Integrated Security = True",attachDbFilename);
我是使用 此连接 字符串
你好Vivek,
>> 创建 设置阅读 只有 是 发生。
一般来说,C盘是一个系统磁盘,不建议存储数据。请尝试将数据库移动到其他驱动器。
另外请将您的代码更改为:
public string Connect()
{
string outputFolder = Path。 GetDirectoryName(Assembly.GetExecutingAssembly()的位置。);
string attachDbFilename = Path.Combine(outputFolder," Database.mdf");
//返回string.Format(@"数据源=(LocalDB)\v11.0;初始目录= LocalDbDemo; AttachDbFilename ="" {0}""; Integrated Security = True",attachDbFilename);
返回string.Format(@"数据源=(LocalDB)\v11.0;初始目录= LocalDbDemo; AttachDbFilename = {0}; Integrated Security = True",attachDbFilename) ;
}然后使用它:
string conn =" @" +'"'+ Connect()+'"';注意:请关闭
上一个帖子 如果你解决了它,那就在新的帖子中提出你的新问题。
问候,
Frankie
string outputFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string attachDbFilename = Path.Combine(outputFolder, "Database.mdf");
return string.Format(@"Data Source=(LocalDB)\v11.0;Initial Catalog=LocalDbDemo;AttachDbFilename=""{0}"";Integrated Security=True", attachDbFilename);
I am using this connection string
Hi Vivek,
>>after creating setup read only is happening.
In general, the C drive is a system disk and it is not recommended to store data. Please try to move your database to other drives.
Also please change your code to:
public string Connect() { string outputFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string attachDbFilename = Path.Combine(outputFolder, "Database.mdf"); //return string.Format(@"Data Source=(LocalDB)\v11.0;Initial Catalog=LocalDbDemo;AttachDbFilename=""{0}"";Integrated Security=True", attachDbFilename); return string.Format(@"Data Source=(LocalDB)\v11.0;Initial Catalog=LocalDbDemo;AttachDbFilename={0};Integrated Security=True", attachDbFilename); }Then use it:
string conn = "@" + '"' + Connect() + '"';Note: Please close the previous thread if you solved it, then ask your new question in a new thread.
Regards,
Frankie
这篇关于无法从c驱动器访问mdf文件,创建设置后只读正在发生。我们需要做什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!