Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save to database doesnt actually change the database

Status
Not open for further replies.

tonyladuk

Programmer
Aug 18, 2006
16
US
I'm having problems saving back to an Access database. There's something i'm missing. I've just downloaded and produced the microsoft example called NorthWind in the hope that this would bring to light my problem.

For those of you that dont know, its a simple customer table and using the wizard you produce a form that runs through the database and alows you to save changes in the data. I've finished it and it seems to work fine, the database during run time updates great.

Here's the issue: When you close the application and open the access database to see the changes, or when you run it again. No changes have been made. This has got to be something crucial i'm missing. I really need some inside help here.
Thanks in advance.
 
If you're using transactions, did you commit your last transaction? If you don't, it'll be held in a pending state forever, and (most) users of the database won't see it's changes.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Are you positive that the data is ever changing in the database? It sounds to me like the updates are never really being successfully executed.

Have you opened the Access DB to veiw the changes while your application is making them?

Senior Software Developer
 
Code:
    Private Sub CustomersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomersBindingNavigatorSaveItem.Click
        Try
            Validate()
            CustomersBindingSource.EndEdit()
            CustomersTableAdapter.Update(Me.NwindDataSet.Customers)
            MsgBox("Update successful")

        Catch ex As Exception
            MsgBox("Update failed")
        End Try

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'NwindDataSet.Customers' table. You can move, or remove it, as needed.
        Me.CustomersTableAdapter.Fill(Me.NwindDataSet.Customers)

    End Sub

This is the microsoft example. My code is below:

Code:
    Public Sub SetAccountsToDataBase()
        Dim dsDataSet As New FPSdataDataSet.accountsDataTable
        Dim dbaAdapter As New FPSdataDataSetTableAdapters.accountsTableAdapter

        For Each AccountRow As AccountTypeStructure In colAccounts
            Dim newAccountsRow As FPSdataDataSet.accountsRow = dsDataSet.NewaccountsRow
            newAccountsRow.ID = AccountRow.intID
            newAccountsRow.username = AccountRow.strUserName
            newAccountsRow.password = AccountRow.strPassword
            newAccountsRow.acctype = AccountRow.strType
            dsDataSet.Rows.Add(newAccountsRow)
            newAccountsRow = Nothing
        Next

        dsDataSet.AcceptChanges()
        dbaAdapter.Update(dsDataSet)
        dsDataSet.AcceptChanges()

        dsDataSet = Nothing
        dbaAdapter = Nothing

        colAccounts.Clear()
        GetAccountsFromDatabase()
    End Sub

And even though it seems as though the database is being affected by the code during run time, ive opened the access database during the changes and it doesnt complain about it and the changes arent made.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top