CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1

    Help with updating table

    Hello all... I am stuck. Can someone get me un stuck?

    First of all, yes this is a project for a class I am taking, I know that, and I dont want anyone to write the app for me, but what I do need is someone to look at the update subs and tell me whats wrong.

    My app simulates an ATM login... it contains two forms, a login form and a main form.

    How it works is basically, the app loads the login form, prompting for an account number and pin. this form has a data connector to the database and it creates a dataset. The form accesses the dataset directly (no binding) to match the account number and pin entered, and passes that to a friend variable in the included module. after that is done, the login form closes and the main form loads.

    When it loads, it pulls a row from the db based on the account number saved in the friend variable in the module. The main form also has a data connector to the db, and has its own dataset as well (the dataset for the login form only includes 2 fields from the db, and the ds for the main form includes all fields from the db).

    Now at this point, the user can make a withdrawal, do a deposit, change pin or name, and logout.

    Here is where I am stuck. The initializaion works fine, and the main form loads with the correct user info based on the the account number given during login. The problem is when I go to do an update to the dataset on the main form. The way it should work is that when the user clicks on the deposit finalize button the app updates that row in the database. That way the deposit, withdrawal, or info change is saved for future use.

    Problem is this line here:

    Code:
    If Not dsmodifiedrows Is Nothing Then
                odbdaCustData.Update(dsmodifiedrows)
                Atm_custData1.AcceptChanges()
            End If
    Now, if i use the if statement, the update never fires because the row is not shown as changed, apparently. If I remove the if statement, the app throws an unknown exception error trying to update with null values or something like that...

    So anyone care to help get me unstuck? I have used the same update setup on several other apps with no problems.

    At first I thought it may have something to do with the db being accessed twice, but I cant see that being a problem, IMHO. Next I thought it may be because the login was creating the dataset using the acct_no and pin fields with readonly permissions set. So I changed the dataset to use share deny none for both forms, but that didnt help.

    I am attaching the entire solution as a zip file... I cant see an issue, but then again, I am not that proficient with vb so I am probably overlooking something.

    Keep in mind that the withdrawal update does not work yet, and the deposit update is the one I have been messing with to figure this out. Some of the buttons are not complete, but all the text boxes work and the bindings are all present.

    Thanks!

    Jeff
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured