如何指定数据库的路径 [英] How to specify the path to my database
问题描述
大家好,
我试图将数据插入我的数据库文件* .sdf
所以,如果我在d:\ project中有.sdf文件\ MyWPF \ App_Data \ Modeld.sdf
理想情况下我的连接字符串是什么。
理想情况下这条路径是正确的:
| DataDirectory | \ App_Data \Mydb.sdf
如果我在调试模式下构建应用程序:那么在我的bin文件夹中让App_data \ MyDb.sdf得到更新,我的原始文件在
d:\projects \ MyWPF \ App_Data \ Modeld.sdf中有时无法正确更新。
每个人都给我的连接字符串为| DataDirectory | \ App_Data \Mydb.sdf
CAn any请告诉我哪里出错了?
Hi All,
I am trying to inset data into my database file *.sdf
So, if i have the .sdf file in d:\projects\MyWPF\App_Data\Mydb.sdf
Ideally What shall be my connection string.
Ideally is this path correct:
|DataDirectory|\App_Data\Mydb.sdf
If i am building my application in Debug mode: then in my bin folder i have App_data\MyDb.sdf that is getting updated and my original file in
d:\projects\MyWPF\App_Data\Mydb.sdf is sometime not getting updated properly.
Everyehere i have given the connection string as |DataDirectory|\App_Data\Mydb.sdf only
CAn anyone pls let me know where i am going wrong??
推荐答案
嗯... D:\Projects \ MyWPF \不太可能是你的数据目录 - 这很可能会导致问题安装在另一台机器上的产品 - 因为您的应用程序将位于Program Files文件夹中并出于安全原因编写难以或不可能的内容。
有一个看看这个:我应该在哪里存储我的数据? [ ^ ] - 它建议一些适合开发和发布的更好的地方。
Um...D:\Projects\MyWPF\ is very unlikely to be your data directory - and it's very, very likely to cause problems in production when installed on another machine - because your app will be in the "Program Files" folder and writing that that is either difficult or impossible for security reasons.
Have a look at this: Where should I store my data?[^] - it suggests some better places which would be appropriate for development and release.
这篇关于如何指定数据库的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!