|
-
Feb 9th, 2003, 04:51 AM
#1
Thread Starter
Addicted Member
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
-
Feb 9th, 2003, 11:21 AM
#2
Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|