save button

chowchow123

Active member
Joined
Sep 6, 2007
Messages
34
Programming Experience
1-3
Hi

I have a series of tabbed forms with toolbar button and I've added a save button but I get errors

VB.NET:
Private Sub MemberSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MemberSave.Click
        Me.Validate()
        Me.Mem_typeBindingSource.EndEdit()
        Me.Mem_typeBindingSource.Update(Me.SandsdbDataSet.member)
    End Sub
error:
'Update' is not a member of 'Myproject.myprojectDataSetTableAdapters.memberTableAdapter'.

VB.NET:
 Private Sub PaymentSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PaymentSave.Click
        Me.Validate()
        Me.ChargesBindingSource.EndEdit()
        Me.ChargesBindingSource.Update(Me.SandsdbDataSet.charges)
    End Sub
error:
'Update' is not a member of 'System.Windows.Forms.BindingSource'

I have bound the toolbars to the correct bindingsource
 
Hi

I have a series of tabbed forms with toolbar button and I've added a save button but I get errors

VB.NET:
Private Sub MemberSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MemberSave.Click
        Me.Validate()
        Me.Mem_typeBindingSource.EndEdit()
        Me.Mem_typeBindingSource.Update(Me.SandsdbDataSet.member)
    End Sub
error:
'Update' is not a member of 'Myproject.myprojectDataSetTableAdapters.memberTableAdapter'.
The stated code will not throw that error (it does not mention a tableadapter). Update is not a static member of a tableadapter and cannot be called without an object instance.

VB.NET:
 Private Sub PaymentSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PaymentSave.Click
        Me.Validate()
        Me.ChargesBindingSource.EndEdit()
        Me.ChargesBindingSource.Update(Me.SandsdbDataSet.charges)
    End Sub
error:
'Update' is not a member of 'System.Windows.Forms.BindingSource'
Update is never a member of a BindingSource. It is a member of a tableadapter.
 
The code below looks right and the table adapter and binding source are connected to the form but I still get the error - where else should I look?

VB.NET:
Private Sub PersonalSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PersonalSave.Click
        Me.Validate()
        Me.MemberBindingSource.EndEdit()
        Me.MemberTableAdapter.Update(Me.SandsdbDataSet.member)
    End Sub

error:
Error 'Update' is not a member of 'MyProject.sandsdbDataSetTableAdapters.memberTableAdapter'.
 
Maybe your tableadapter has no ability to modify the results; readonly tableadapters do not have an .Update() method. An adapter becomes readonly if the wizard determines that the query in use is not updateable (maybe it uses a join) - it creates only the SELECT, and ignores the INSERT UPDATE and DELET queries
 
Thanks for the explanation

I think it may have somehow become readonly -

I have 2 forms which are identical one where the cells are readonly - and the other where you can edit the data - both forms are connected to the same table - maybe that's how it's become readonly -

How could I change so that it can modify results?

Thanks
 
Ensure that the relevant tableadapter has, (in design view) at least one of the data modifying queries
 
How would a generic update query look like?

Update member
Set (mem_id=@mem_id) AND(forename=@forename)....all rows
WHERE (mem_id=@mem_id)......all rows?
 
its rare you update a PK field, so mem id wouldnt appear in the SET clause.. plus, think about it.. the mem id youre updating is the same as what is being used to update it..

Pointless SQL:
UPDATE table SET name = 'john' WHERE name = 'john'

If the tableadapter is based on just one table, ensure that table has a primary key, then delete and regenerate the tableadapter..
 
Hi
Thanks Cjard - just a query

I manage to solve the update problem for the main table - I have another table that has a left join on mem_id as below
VB.NET:
SELECT trial_membership.mem_id as trial_mem, trial_1, trial_2, trial_3, trial_4, trial_5, trial_6, trial_7, trial_8, trial_9, trial_10
FROM  trialmem_record, trial_membership
WHERE trialmem_record.mem_id = trial_membership.mem_id

like you mentioned - mem_id would never change or update - so this shouldn't be part of an update query - however the other fields will need updating - do I do a separate query excluding mem_id and apply the update on it?
 
I need mem_id automatically inserted from trial_membership into trialmem_record and each row in trialmem_record to be associated with mem_id in trial_membership
 
Last edited:
I'm not quite sure I understand. What are the schema and the example data of your two tables, before and after your user uses the GUI?
 
Back
Top