我运行代码后,我的访问文件数据会转到以前的数据 [英] My data of access file goes to previous data as soon as I run the code

查看:52
本文介绍了我运行代码后,我的访问文件数据会转到以前的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在使用vb.net制作工资计划。

因为我使用了Access数据库以及在程序中创建的DatSet。 />
在创建DataSet时,它表示要在程序文件夹外部的数据库ID要复制到文件夹中。在那个阶段,我在网上的许多教程中选择了YES。



现在主要的问题是,如果我通过程序在数据库中插入数据,它会产生一个应用程序启动路径所在的Debug文件夹中的数据库副本。

没关系。



我在数据库中插入数据应用程序启动路径所在的Debug文件夹。



但是一旦程序关闭并再次启动调试,调试文件夹中的数据库就会回到之前的状态它位于主项目文件夹中。



我尝试过:



任何人都可以帮助我,因为我是数据集的新手。我无法理解这个问题。

Hi all
I am using vb.net to make the salary program.
in that i had used Access Database along with DatSet created in the program.
While creating the DataSet it say that the database id outside the program folder do you want to copy in folder. In that phase i chose YES as described in many tutorial over the net.

Now the main problem is that if i insert the data in database through the program it make a copy of database inside Debug folder where the application startup path is.
that is OK.

I'm inserting the data in database inside the Debug folder where the application startup path is.

But once the program is closed and debugging is started again the database in the debug folder goes back to the previous state what it is in the main project folder.

What I have tried:

Could any one please help me as I am new to the dataset. I am not able to understand the problem.

推荐答案

好的是......它会的。

你在做什么就是说是 - 每次运行时,将调试文件夹中的版本复制到主文件夹。然后将您的代码更改应用于刚刚创建的数据的副本。编程退出时,这些更改不会复制回调试文件夹,而是保留在主目录中的副本中。



这正是应该发生的事情: debug文件夹包含复制到working文件夹的完美版本的数据,这样如果你的应用程序在开发中犯了很大的错误,你就不会在下次运行它时丢失基础信息。 $>


而不是这样做,在App data文件夹下创建一个文件夹:打开Windows资源管理器并输入%LocalAppdata%作为地址。按ENTER键,它将转到本地文件夹。创建一个名为Test Data的文件夹,然后将其打开。在里面创建一个名为app name的文件夹。打开它。在里面创建一个名为Good Data的文件夹。

现在打开第二个Windows资源管理器实例,浏览Debug文件夹。将数据库文件复制到您创建的文件夹中,这样您就可以获得实时和好的副本。

现在从调试和主应用程序文件夹中删除它,并从中删除文件链接你的应用程序。

回到第一个Windows资源管理器窗口,然后在地址栏中单击一次 - 这将为您提供实时文件夹的路径 - 在我的情况下将是:

Well yes ... it will.
What you are doing is saying "yes - copy the version in the debug folder to the main folder" each time you run it. Changes your code then makes are applied to the copy of the data you just created. When you program exits, those changes are not copied back to the debug folder but are retained in the copy in the main directory.

This is exactly what should happen: the debug folder holds a "perfect" version of the data which is copied to the "working" folder so that if your app makes huge mistakes in development, you don't lose the "base" information for next time you run it.

Instead of doing this, make a folder under the "App data" folder: open Windows Explorer and enter "%LocalAppdata%" as the address. Press ENTER and it will take you to the Local folder. Create a folder called "Test Data", and open it. Create a folder inside that called your app name. Open it. Create a folder inside that called "Good Data".
Now open a second Windows Explorer instance, and browse top your Debug folder. Copy the database file to both the folder you created, so you have a "live" and a "good" copy.
Now deleted it from your debug and main app folders, and remove the file link from your app.
Go back to the first Windows Explorer window, and click once in the address bar - that will give you the path to the "live" folder - in my case that would be:
C:\Users\PaulG\AppData\Local\Test Data\MyAppName

复制它,并在连接字符串中使用它你加载到你的应用程序。

当你把数据库弄糟时,只需将它从Good Data文件夹复制回Live文件夹。

Copy that, and use it in the connection string you load into your app.
When you muck the DB up, just copy it from the "Good Data" folder back to the "Live" folder.


这篇关于我运行代码后,我的访问文件数据会转到以前的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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