Results 1 to 2 of 2

Thread: deleting row from table

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    175

    Question deleting row from table

    hi alll
    i have
    *******dataset**********
    dscompanies 1

    *********tables in the dataset**********
    a) res
    b) T_Companies

    both conncted with 1:m relation T_resT_companies (1 company can have many records in res)

    *********datagrid***************
    grdConnWay
    datasource = T_companies.defaultview
    datamember = T_Companies.T_resT_companies



    so when i sand on companies grid (not mentioned here) its retrives all the res details.

    my question is when i stand on grdConnWay - and want to delete row i should delete it from the res table - how do i do that?
    or how i retrieve the key value?
    i hope i clarify myself as well...
    thanks to all

  2. #2
    Member
    Join Date
    Dec 2002
    Location
    NY, USA
    Posts
    52
    Private Sub cmd_DeleteRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_DeleteRow.Click

    'Delete a Row and commit the changes to the Dataset
    Dim strFilter As String = CType(Me.TextBox1.Text, Int32)
    Dim oTempRow As DataRow = oDS.Tables("DATA").Rows.Find(strFilter)

    If Not IsNothing(oDS) And Not IsNothing(oTempRow) Then
    oDS.Tables("DATA").Rows.Remove(oTempRow)
    End If
    oDS.AcceptChanges()

    End Sub

    requires Index on the Datatable


    after that delete the related rows in the child record


    Another approach is to create relationships between 2 tables and set referentioal integrity on Delete
    Iouri Boutchkine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width