使用vb.net将数据临时保存到ms访问数据库 [英] Data are saved temporary to an ms access database using vb.net

查看:98
本文介绍了使用vb.net将数据临时保存到ms访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用vb.net将数据临时保存到ms访问数据库,当我终止应用程序时,数据会自动从数据库中删除



如何解决这个问题问题..?



以下代码

Data are saved temporary to an ms access database using vb.net, when I terminate the application the data are automatically deleted from database

how can i solve this problem..?

code given below

Dim ConnnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<database_name>.mdb"
Dim cn As New OleDbConnection(ConnnectionString)
cn.Open()


Dim db As String = "INSERT INTO <table> VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox2.Text & "')"
Dim da As New OleDbCommand(db, cn)
Dim rd As OleDbDataReader
rd = da.ExecuteReader();
da.ExecuteNonQuery()
cn.Close()

推荐答案

在大多数情况下会出现这种情况,因为数据库放在项目的根目录或子文件夹中。

移动数据库... Project \ ... Project \Bin \ ... Project \Bin \Debug 任意其他文件夹的文件夹,例如: D:\ MyDatabase \ ;)



如果不起作用,请再次致电。
In most cases this behaviour occurs because the database is placed in a root directory of project or inside one of subfolder.
Move the database from ...Project\ or ...Project\Bin\ or ...Project\Bin\Debug folder to any other folder, for example: D:\MyDatabase\ ;)

Call again, if it won't help.


一旦将数据写入数据库,它就永久存在,直到某些代码出现并删除它。所以,无论是什么删除这些数据,如果事实上它实际上被删除了,它发生在你的代码中,或者某个其他应用程序连接到同一个数据库,而不是因为你的应用程序被终止了。
Once you write the data to the database, it's there, permanently, until some code comes along and deletes it. So, whatever is "deleteing" this data, if in fact it's actually being deleted, it's happening in your code somewhere, or some other app connecting to the same database, and not because your application was terminated.


这篇关于使用vb.net将数据临时保存到ms访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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