Click here to Skip to main content
15,894,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
how to delete rows from table which is stored insqlerver using data realation
can u guide or send any snippets


C#
DataColumn parentColumn =
           DataSet1.Tables["person"].Columns["sno"];
        DataColumn childColumn =
           DataSet1.Tables["dept"].Columns["no"];
        // Create DataRelation.
        DataRelation relCustOrder;
        relCustOrder = new DataRelation("CustomersOrders",
            parentColumn, childColumn);
        // Add the relation to the DataSet.
        DataSet1.Relations.Add(relCustOrder);
        //DataSet1.Relations.Add(relCustOrder);
        ForeignKeyConstraint fkeyConstraint = new ForeignKeyConstraint("fkey", parentColumn, childColumn);
        fkeyConstraint.DeleteRule = Rule.SetNull;



from what i can i do to delete rows
Posted
Updated 21-Feb-12 21:14pm
v3
Comments
Nilesh Patil Kolhapur 22-Feb-12 3:07am    
Give Some details what u try?
kingsa 22-Feb-12 3:11am    
DataColumn parentColumn =
DataSet1.Tables["person"].Columns["sno"];
DataColumn childColumn =
DataSet1.Tables["dept"].Columns["no"];
// Create DataRelation.
DataRelation relCustOrder;
relCustOrder = new DataRelation("CustomersOrders",
parentColumn, childColumn);
// Add the relation to the DataSet.
DataSet1.Relations.Add(relCustOrder);
//DataSet1.Relations.Add(relCustOrder);
ForeignKeyConstraint fkeyConstraint = new ForeignKeyConstraint("fkey", parentColumn, childColumn);
fkeyConstraint.DeleteRule = Rule.SetNull;
kingsa 22-Feb-12 3:13am    
from there how can i delete particular row from a table

1 solution

If the relations in DataBase is Cascading,in property of that relation ,in Insert and Update Specification, select Cascade for Delete Role.
.net Automatically delete the related tables.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900