这是我在访问数据库中添加新数据的简单代码。
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)
当我运行我的应用程序时,它正常工作,但是当我重新启动应用程序数据库时,不会更新。为什么会这样?