Hey all!
On my form, there aretextboxes for all the various fields. the user must enter data into the boxes and then click on the "Add Record" button. This will then create a new record with the data the user has entered.
It works mostly ok, as it adds the new record onto the end of the table, but then it also replaces the first record with the fields the user has entered as well.
Here is my code:
Any idea's as to how i can solve this issue?
Also, for some reason, the changes i make to the database via my application program don't affect my database, i.e. after i close the program, the database reverts to what it was before i ran the program. My database datasource has a build action of "Compile" and Copy to output directory of "Copy Always"
Thanks
Laura
On my form, there aretextboxes for all the various fields. the user must enter data into the boxes and then click on the "Add Record" button. This will then create a new record with the data the user has entered.
It works mostly ok, as it adds the new record onto the end of the table, but then it also replaces the first record with the fields the user has entered as well.
Here is my code:
Code:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] CmdAdd_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] CmdAdd.Click[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dataR [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] payrollDatabaseDataSet.Allowances_Pay_TableRow[/SIZE]
[SIZE=2]dataR = PayrollDatabaseDataSet.Allowances_Pay_Table.NewRow[/SIZE]
[SIZE=2][COLOR=#008000]' fill variables[/COLOR][/SIZE]
[SIZE=2]dataR.employee_ID = Employee_IDTextBox.Text[/SIZE]
[SIZE=2]dataR.allowances_ID = Allowances_IDTextBox.Text[/SIZE]
[SIZE=2]dataR.allowances_amount = Allowances_amountTextBox.Text[/SIZE]
[SIZE=2][COLOR=#008000]' update records[/COLOR][/SIZE]
[SIZE=2]PayrollDatabaseDataSet.Allowances_Pay_Table.Rows.Add(dataR)[/SIZE]
[SIZE=2]Allowances_Pay_TableTableAdapter.Update(PayrollDatabaseDataSet.Allowances_Pay_Table)[/SIZE]
[SIZE=2][COLOR=#008000]' display first record in(database)[/COLOR][/SIZE]
[SIZE=2]current_row = 0[/SIZE]
[SIZE=2]ShowCurrentRecord()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
Any idea's as to how i can solve this issue?
Also, for some reason, the changes i make to the database via my application program don't affect my database, i.e. after i close the program, the database reverts to what it was before i ran the program. My database datasource has a build action of "Compile" and Copy to output directory of "Copy Always"
Thanks
Laura