visual basic and microsoft access database connection

时间:2018-03-25 19:25:05

标签: visual-studio ms-access

Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'Database4DataSet.Table1' table. You can move, or remove it, as needed.
    Me.Table1TableAdapter.Fill(Me.Database4DataSet.Table1)

End Sub

Private Sub BtnPrevious_Click(sender As Object, e As EventArgs) Handles BtnPrevious.Click
    Table1BindingSource.MovePrevious()
End Sub

Private Sub btnfirst_Click(sender As Object, e As EventArgs) Handles btnfirst.Click
    Table1BindingSource.MoveFirst()
End Sub

Private Sub BtnNext_Click(sender As Object, e As EventArgs) Handles BtnNext.Click
    Table1BindingSource.MoveNext()
End Sub

Private Sub BtnLast_Click(sender As Object, e As EventArgs) Handles BtnLast.Click
    Table1BindingSource.MoveLast()
End Sub

Private Sub btnadd_Click(sender As Object, e As EventArgs) Handles btnadd.Click
    Table1BindingSource.AddNew()
End Sub

Private Sub btndelete_Click(sender As Object, e As EventArgs) Handles btndelete.Click
    Table1BindingSource.RemoveCurrent()
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Try
        Me.Validate()
        Me.Table1BindingSource.EndEdit()
        Me.Table1TableAdapter.Update(Me.Database4DataSet)
        MsgBox("Your information has been saved successfully")
    Catch ex As Exception
        MsgBox("Please try again")
    End Try

End Sub

Hi i am trying to create a simple vb application that connects to a Microsoft access database that stores basic information of student name, id number and result. my code is working to an extent but when i run the program and add new records the new data i entered saves no problem and i can see while the program is running but when i stop de bugging and start de bugging again the new information i added to the database the last time doesn't appear. only the information that i inputted originally into the database through the access file show up. any info or help would be appreciated.

0 个答案:

没有答案