尝试为文件附加自动命名的数据库失败. [英] An attempt to attach an auto-named database for file failed.
本文介绍了尝试为文件附加自动命名的数据库失败.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我已经使用LINQ to SQL创建了Windows应用程序.成功部署应用程序后,我收到以下错误消息:"为文件<文件名>附加自动命名数据库的尝试失败".我们在app.config文件中具有连接字符串,如下所示
Hello,
I have created a windows application using LINQ to SQL. After successfully deploying the application i''m getting the error as "An attempt to attach an auto-named database for file <File Name> failed". We have the connection string in app.config file as follows
<add name="localserver" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=filepath\bin\Debug\MyDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
How to remove this error?
推荐答案
在您的连接字符串中,只需添加"database =<数据库名称>".这会阻止SQL Server创建自动命名的数据库.
In you connection string just add the ''database=<database name>''. This prevents SQL server to create the auto-named database.
将数据库文件保留在部署文件夹中.
keep the database file in deployment folder.
这篇关于尝试为文件附加自动命名的数据库失败.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文