如何在窗口应用程序中添加App_Data文件夹? [英] How Do I Add An App_Data Folder In Window Application?

查看:63
本文介绍了如何在窗口应用程序中添加App_Data文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的窗口应用程序中添加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" />

推荐答案

1.You可以使用解决方案资源管理器在Windows应用程序中添加和/或创建任何文件夹。



2.在添加包含的文件夹后,关注数据库文件在Windows应用程序的子文件夹中的数据库中,您必须更改连接字符串中的 AttachDbFilename ,以指向新文件夹中的.MDF文件。
1.You could add and/or create any folder in your windows application, by using "Solution Explorer".

2.Regarding your database file, after you add the folder that contains the database in a subfolder of your windows application, you have to change the AttachDbFilename in your connection string, to point to the .MDF file from your new folder.


这篇关于如何在窗口应用程序中添加App_Data文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆