Updating rows in a dataset

Nicko101

Member
Joined
Aug 31, 2004
Messages
10
Programming Experience
Beginner
How do i find a specific row in a dataset and update it using data from textboxes? I currently have the following code

VB.NET:
 [color=#0000ff]
Private[/color] [color=#0000ff]Sub[/color] btnEdit_Click([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] System.Object, [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] btnEdit.Click
Songs.song.LoadDataRow((add.txtName.Text, add.txtWords.Text), True)
[color=#0000ff]If[/color] add.ShowDialog = DialogResult.OK [color=#0000ff]Then[/color]
Hymns6.Hymn.LoadDataRow((add.txtName.Text, add.txtWords.Text), [color=#0000ff]True[/color])
[color=#0000ff]End[/color] [color=#0000ff]If[/color]
[color=#0000ff]End[/color] [color=#0000ff]Sub
[/color]

This doesnt work, but Songs is the name of the dataset, song is the table, add is the name of the dialog box used and txtname and txtwords are the two textboxes i want to use to update the dataset.

Thankyou
 
Last edited:

Nicko101

Member
Joined
Aug 31, 2004
Messages
10
Programming Experience
Beginner
I have got a listbox, a button and a label in my form. the listbox shows the data from the first column, and the label shows the data from the same row, but the next column. When you click the button a dialog box appears with two textboxes and a button. the two textboxes contain the selected item from the listbox and the information from the label. both pieces of data come from the dataset. You can change the text in the textboxes, then when you click the button, it updates the dataset with the new information and displays the first form. I think i have solved my own problem though, instead of using LoadDataRow, i can use

VB.NET:
 If add.Showdialog = dialogresult.ok then 
Songs.song.Rows(listbox1.selectedindex)Item.(0) = add.txtName.text
Songs.song.Rows(listbox1.selectedindex)Item.(1) = add.txtWords.text
End if

I think this works for what i need.
 
Top Bottom