如何在C#中插入mybook.accdb? [英] How can I insert mybook.accdb in C#?

查看:49
本文介绍了如何在C#中插入mybook.accdb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我的问题是我有一个MS Access文件,即C#中的textbook.accdb我使用以下代码



System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection();

con.ConnectionString =Provider = Microsoft.ACE.OLEDB.12.0; Data Source =+ Application.StartupPath +\\ textbook。 accdb;



上面的代码在调试时编译完美但是在发布软件并安装之后,软件安装时所述的textbook.accdb文件已经丢失了访问已安装软件中的数据。我该怎么办?



我的尝试:



我尝试了下面的代码:

System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection();

con.ConnectionString =Provider = Microsoft。 ACE.OLEDB.12.0;数据源=+ Application.StartupPath +\\ textbook.accdb;

Sir, my problem is I have an MS Access file i.e. textbook.accdb in C# I use the following code

System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\textbook.accdb";

The above code compile perfect in debugging however after publish the software and install it, the said textbook.accdb file has been missing while software installation and could not access the data in the installed software. what should I do?

What I have tried:

I tried the following code:
System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\textbook.accdb";

推荐答案

问题在于开发,访问应用程序文件夹不受保护 - 当您安装它时,它是Program Files(或program files(x86))文件夹的一部分,该文件夹受到保护以减少病毒活动。

基本上,不要将任何数据文件放在应用程序文件夹中。

见这里:我应该在哪里存储我的数据? [ ^ ]它解释了问题,显示了一些很多东西地点,以及如何访问它们。
The problem is that in development, access to the application folder isn't protected - when you install it, it's part of the "Program Files" (or "program files(x86)") folder, which is protected to reduce virus activity.
Basically, don't put any data files in the application folder.
See here: Where should I store my data?[^] it explains the problem, shows some much better places, and how to access them.


这篇关于如何在C#中插入mybook.accdb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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