My tables in MS Access doesn't have any change which it did not update the record that I entered in Visual Studio.. This is my code.

 Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
        On Error GoTo saveErr
        RequestSoftwareBindingSource.EndEdit()
        RequestSoftwareTableAdapter.Update(FYPDataSet.RequestSoftware)
        MessageBox.Show("Your request has been submitted.", "Thank you", MessageBoxButtons.OK, MessageBoxIcon.Information)
saveErr:
        txtName.Text = ""
        txtDate.Text = ""
        txtSubject.Text = ""
        txtSoftware.Text = ""
        txtLabNum.Text = ""
    End Sub

I'm glad if there's anyone can helpp me with this problem.. Thanks. :)

Recommended Answers

All 6 Replies

Hi

How is the DataSet and TableAdapters being setup? Is this all done via wizards in Visual Studio?

Also, I would strongly recommend that you avoid the use of GoTo statements, especially in the context that you are using them. Instead, look at Try/Catch which is the exception handling mechanism available to you in .NET.

So an example might be:

Try
    RequestSoftwareBindingSource.EndEdit()
    RequestSoftwareTableAdapter.Update(FYPDataSet.RequestSoftware)
    MessageBox.Show("Your request has been submitted.", "Thank you", MessageBoxButtons.Ok, MessageBoxIcon.Information)
Catch ex As Exception
    MessageBox.Show(ex.Message)
Finally
    txtName.Text = ""
    txtDate.Text = ""
    txtSubject.Text = ""
    txtSoftware.Text = ""
    txtLabelNum.Text = ""
End Try

HTH

@djjeavons Thanks for your help.. I already done your method.. but it still did not work..I set a form as user input. And I have another form that only have data grid view. When i click the button,the record only work once,means, the second time did not recorded. It only updated in dgv,but not in my table in MS Access..

`Public Class Registration

Private Sub LecturerLoginBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles LecturerLoginBindingNavigatorSaveItem.Click
    Me.Validate()
    Me.LecturerLoginBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.FYPDataSet)

End Sub

Private Sub Registration_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'FYPDataSet.StaffLogin' table. You can move, or remove it, as needed.
    Me.StaffLoginTableAdapter.Fill(Me.FYPDataSet.StaffLogin)
    'TODO: This line of code loads data into the 'FYPDataSet.LecturerLogin' table. You can move, or remove it, as needed.
    Me.LecturerLoginTableAdapter.Fill(Me.FYPDataSet.LecturerLogin)

End Sub

Private Sub btnRegisterL_Click(sender As Object, e As EventArgs) Handles btnRegisterL.Click
    Dim newRow As FYPDataSet.LecturerLoginRow
    newRow = FYPDataSet.Tables("LecturerLogin").NewRow
    newRow.IDNum = txtIDL.Text
    newRow.Username = txtUsernameL.Text
    newRow.Password = txtPasswordL.Text
    Try
        FYPDataSet.Tables("LecturerLogin").Rows.Add(newRow)
        LecturerLoginBindingSource.EndEdit()
        LecturerLoginTableAdapter.Update(FYPDataSet.LecturerLogin)
        Me.LecturerLoginTableAdapter.Fill(Me.FYPDataSet.LecturerLogin)
        MessageBox.Show("Registration Done !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Me.Hide()
        Form1.Show()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    Finally
        txtIDL.Text = Nothing
        txtUsernameL.Text = Nothing
        txtPasswordL.Text = Nothing
    End Try
End Sub

`End Class``

this is my interface

and this is my code at form1.vb
`Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'FYPDataSet.LecturerLogin' table. You can move, or remove it, as needed.
    Me.LecturerLoginTableAdapter.Fill(Me.FYPDataSet.LecturerLogin)
    LecturerLoginBindingSource.AddNew()

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Me.Hide()
    Registration.Show()
End Sub

`End Class``

When i click the button,the record only work once,means, the second time did not recorded.

Is your database part of your solution? If so, can you check the properties on the database to ensure that the Copy To Output Directory is set to "Do Not Copy" for now. I believe (but could be wrong) that it is set to "Copy always" which means that it could be overwriting your database each time the program is run.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.