Vb.net 为什么我的Access数据库没有更新?
这是我在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
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)
当我运行应用程序时,它会正常工作,但当我重新启动应用程序时,数据库不会更新。为什么会发生这种情况?数据库是在您的解决方案中还是从某个地方复制的?每个生成都将覆盖您更新的生成。是否在项目文件之间列出了数据库文件?如果是,属性“复制到输出目录”的设置是什么?阅读此内容了解如何管理本地数据文件: