C# 数据库文件目录

发布于 2024-09-06 04:26:25 字数 698 浏览 0 评论 0原文

我正在使用 Windows Forms 应用程序和 MS Access 数据库。我想知道是否有一种方法可以显示数据库文件的目录(在其中保存数据),除了这样:

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=save.mdb ”;

        OleDbConnection empConnection = new OleDbConnection(conString);


        string insertStatement = "INSERT INTO zivila "
                             + "([naziv],[kalorij],[beljakovin],[oh],[mascob]) "
                             + "VALUES (@naziv,@kalorij,@beljakovin,@oh,@mascob)";

或这样:

  • “数据源=D:\Simonova aktovka na namizju\matura\test5\save.mdb”;

因为如果我使用第一个应用程序,则应用程序会撤消我关闭它时所做的更改(应用程序) 第二个使我每次将应用程序带到另一台计算机时都必须更改路径(因为目录与 coars 不同) 那么……还有别的办法吗?

I'm using the windows forms aplication with an ms access database. And i would like to know if there is a way to show the directory of the database file (to save data in it)excpet like this:

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=save.mdb";

        OleDbConnection empConnection = new OleDbConnection(conString);


        string insertStatement = "INSERT INTO zivila "
                             + "([naziv],[kalorij],[beljakovin],[oh],[mascob]) "
                             + "VALUES (@naziv,@kalorij,@beljakovin,@oh,@mascob)";

or this:

  • "Data Source=D:\Simonova aktovka na namizju\matura\test5\save.mdb";

couse if i use the first one the aplication undos the changes i've made when i close it(the aplication)
the second one makes me have to change the path everytime i bring the aplication to another computer(cous the direktory is different of coars)
So... is there another way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゝ偶尔ゞ 2024-09-13 04:26:25

试试这个:

Data Source=|DataDirectory|\save.mdb

Try this:

Data Source=|DataDirectory|\save.mdb
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文