I can load my edit form withthe selected account from the datagridview on form1
I can update aany of my information but when I save the information it updates the first account in the database.
How do I save to the selected account only?

This is my save button:

'saves the updates to the database and closes form
        Dim intResponse As String
        intResponse = MsgBox("Do you want to SAVE Changes to this record?", vbOKCancel, "Save?")
        If intResponse = vbOK Then
            '    PbDealersDS.dealer(0).Address_Line1 = Address_Line1TextBox.Text

            AutoBillDS.Customer(0).Location = TxtLocation.Text
            AutoBillDS.Customer(0).Attention = TxtAttention.Text
            AutoBillDS.Customer(0).Address = TxtAddress_Line1.Text
            AutoBillDS.Customer(0).City = TxtCity.Text
            AutoBillDS.Customer(0).State = TxtState.Text
            AutoBillDS.Customer(0).Zip = TxtB_Zip.Text
            AutoBillDS.Customer(0).Phone = MTBPhone.Text
            AutoBillDS.Customer(0).Anniversary = LblAnniversary.Text
            'AutoBillDS.Customer(0)Last_Update = LblUpdated.Text
            AutoBillDS.Customer(0).Comments = TxtComments.Text
            AutoBillDS.Customer(0).Bill_To = TxtBill_To.Text
            AutoBillDS.Customer(0).Attent_to = TxtAttention_2.Text
            AutoBillDS.Customer(0).Address_to = TxtB_address.Text
            AutoBillDS.Customer(0).City_to = TxtB_City.Text
            AutoBillDS.Customer(0).State_to = TxtB_State.Text
            AutoBillDS.Customer(0).Zip_to = TxtB_Zip.Text
            AutoBillDS.Customer(0).Phone_to = MTBB_Phone.Text
            AutoBillDS.Customer(0).Next_Billing = DTP1NextBDate.Text
            AutoBillDS.Customer(0).Monthly = RBMonthly.Checked
            'AutoBillDS.Customer(0).Bi-Monthly = RBBMonthly.Checked
            AutoBillDS.Customer(0).Quarterly = RBQuarterly.Checked
            AutoBillDS.Customer(0).Annual = RBAnnual.Checked
            AutoBillDS.Customer(0).Bi_Annual = RBBAnnual.Checked
            'AutoBillDS.Customer(0).Late_Charge = TxtLate.Text
            AutoBillDS.Customer(0).Use_late = CBUseFlat.Checked
            'AutoBillDS.Customer(0).Flate_Rate = TxtFlatRate.Text
            'AutoBillDS.Customer(0).Current_Charges = TxtCCharges.Text
            'AutoBillDS.Customer(0).Billing_Cycle = CheckBox10.Checked
            'AutoBillDS.Customer(0).Auto_Invoice = CheckBox8.Checked
            'AutoBillDS.Customer(0).Auto_Statement = CheckBox7.Checked
            'AutoBillDS.Customer(0).Bank_Account = TxtBankAccount.Text
            'AutoBillDS.Customer(0).Routing = TxtRoutingNumber.Text
            'AutoBillDS.Customer(0).Credit_Card = TxtCreditCard.Text
            'AutoBillDS.Customer(0).Exp_Date = TxtExpDate.Text

            Me.Validate()
            Me.CustomerBindingSource.DataSource.GetType()
            Me.CustomerBindingSource.EndEdit()
            Me.CustomerTableAdapter1.Update(AutoBillDS)
            Me.TableAdapterManager.UpdateAll(AutoBillDS)
            MsgBox("Updates Successfully Saved to Customer DataBase")
            Me.Close()
        End If
       
        If vbCancel Then
            Exit Sub
        End If

This is because you are using the record number 0 of the Customer datatable to put the new values.

You need to know the shown record position (value for the index instead of 0) to do the updates.

Hope this helps.

Thank you I'll have to look into how I can retrieve the account number I'm working with and have it placed where the (0) is

any Ideals on how to retrieve my position (selected account number(textxBox)) and pace it where the (0) is in my save statement?

Im not in front of visual studio but I think you can use following.
See if it works.

dim rowPosition as integer = DataGridViewName.CurrentCellAddress.y
dim columnPosition as integer = DataGridViewName.CurrentCellAddress.X

You are retrieving the info from TxtLocation.Text to update the record.

Did you filled this TxtLocation.Text with some data 'coming' from the datatable or just always is a new record to add?

Yes The txtLocation comes from the database as the account_number and loads to the text location I need to save changes made to that account number not my first position in the database.

You are retrieving the info from TxtLocation.Text to update the record.

Did you filled this TxtLocation.Text with some data 'coming' from the datatable or just always is a new record to add?

Yes The txtLocation comes from the database as the account_number and loads to the text location I need to save changes made to that account number not my first position in the database.

There are many approaches to solve your issue, and I would suggest two of them:

Use a dataview (a filter over the datatable to locate the right row) , then update it.

Do a foreach loop over the datarows in the datatable. When you find the right row to update, then update it and exit the foreach.

Hope this helps

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.