All pastes #595008 Raw Edit

Miscellany

public text v1 · immutable
#595008 ·published 2007-06-29 07:52 UTC
rendered paste body
        Dim dr As New OleDb.OleDbDataAdapter("SELECT * FROM TRAINEES", libr.objConnection)

        Dim ds As New DataSet

        dr.Fill(ds)

        ds.Tables(0).TableName = "TRAINEES"

        Dim row As DataRow
        row = ds.Tables(0).NewRow
        row.Item("trn_name") = Me.txtName.Text
        row.Item("trn_surname") = Me.txtSurname.Text

        ds.Tables.Item(0).Rows.Add(row)

        ds.AcceptChanges()

        'Just to see if it has been added
        Dim i As Integer
        For i = 0 To ds.Tables.Item(0).Rows.Count - 1
            MessageBox.Show(ds.Tables.Item(0).Rows(i).Item(1))
        Next

        'To commit the changes and see how many rows have been affected (which should be one)
        MessageBox.Show(dr.Update(ds))