问题描述
如何在我的窗口应用程序中添加App_Data。实际上我正面临一个问题,比如
尝试为文件c附加一个自动命名的数据库:\inetpub \wwwroot \ Demo \ App_Data \ aspnetdb.mdf失败了。存在一个具有相同名称的数据库,或者无法打开指定的文件,或者它位于UNC共享上。
对于此错误,我得到一篇文章说保持。如果我们将路径作为AttachDbFilename = |给出,则在App_Data文件夹中的mdf文件DataDirectory | / Database.mdf; (截至目前我正在给出相同的路径)在连接字符串中。所以我需要在窗口应用程序中的App_Data文件夹,如果不是如何解决这个错误。
我的连接字符串为休闲:
< add name =BCT>
connectionString =Data Source = .\SQLEXPRESS; AttachDbFilename = | DataDirectory | \ SQL2005_652242_bct_data.mdf; Integrated Security = True;连接超时= 30;用户实例=真
providerName =System.Data.SqlClient/>
How do i add an App_Data in my window application. Actaully i am facing an issue like
An attempt to attach an auto-named database for file c:\inetpub\wwwroot\Demo\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
For this error i got an article saying that keep .mdf file in App_Data folder if we give path as AttachDbFilename = | DataDirectory | / Database.mdf; (as of now i am giving same path) in connection string. so i need an App_Data folder in window application if not how to solve this error.
my connection string as fallows:
<add name="BCT">
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SQL2005_652242_bct_data.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
推荐答案
这篇关于如何在窗口应用程序中添加App_Data文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!