Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 为什么我的Access数据库没有更新?_Vb.net_Ms Access - Fatal编程技术网

Vb.net 为什么我的Access数据库没有更新?

Vb.net 为什么我的Access数据库没有更新?,vb.net,ms-access,Vb.net,Ms Access,这是我在access数据库中添加新数据的简单代码 Dim i, sno As Integer Dim sname As String Dim rw As DataRow 'Add a new row to the Student table. rw = DataSet11.Tables(0).NewRow sno = InputBox("Enter the Roll no of the Student:") sname = InputBox("Enter the Name of the Stud

这是我在access数据库中添加新数据的简单代码

Dim i, sno As Integer
Dim sname As String
Dim rw As DataRow
'Add a new row to the Student table.
rw = DataSet11.Tables(0).NewRow
sno = InputBox("Enter the Roll no of the Student:")
sname = InputBox("Enter the Name of the Student:")
rw.Item("SNo") = sno
rw.Item("SName") = sname
Try
    DataSet11.Tables(0).Rows.Add(rw)
    'Update the Student table in the testdb database.
    i = OleDbDataAdapter1.Update(DataSet11)
Catch ex As Exception
    MessageBox.Show(ex.Message)
End Try
'Displays number of rows updated. 
MessageBox.Show("no of rows updated=" & i)

当我运行应用程序时,它会正常工作,但当我重新启动应用程序时,数据库不会更新。为什么会发生这种情况?

数据库是在您的解决方案中还是从某个地方复制的?每个生成都将覆盖您更新的生成。是否在项目文件之间列出了数据库文件?如果是,属性“复制到输出目录”的设置是什么?阅读此内容了解如何管理本地数据文件: