Click here to Skip to main content
15,920,005 members
Home / Discussions / Database
   

Database

 
GeneralRe: Fast SELECT Count Pin
Luca Leonardo Scorcia11-Oct-02 6:55
professionalLuca Leonardo Scorcia11-Oct-02 6:55 
GeneralRe: Fast SELECT Count Pin
Daniel Turini14-Oct-02 0:55
Daniel Turini14-Oct-02 0:55 
QuestionOnly 255 char? Pin
Rickard Andersson2010-Oct-02 21:30
Rickard Andersson2010-Oct-02 21:30 
AnswerRe: Only 255 char? Pin
Mazdak10-Oct-02 22:01
Mazdak10-Oct-02 22:01 
GeneralRe: Only 255 char? Pin
Rickard Andersson2010-Oct-02 22:40
Rickard Andersson2010-Oct-02 22:40 
GeneralRe: Only 255 char? Pin
Nick Parker11-Oct-02 1:31
protectorNick Parker11-Oct-02 1:31 
GeneralRe: Only 255 char? Pin
Rickard Andersson2011-Oct-02 2:05
Rickard Andersson2011-Oct-02 2:05 
GeneralCascading delete in a self-joined table Pin
Wjousts10-Oct-02 10:14
Wjousts10-Oct-02 10:14 
I have a treeview that is populated from a self joined table in a way analogus to that detailed by Gevik in his article:
http://www.codeproject.com/useritems/2dtreeview.asp#xx281692xx[^]

Now I've been trying to work out the most efficent way to delete a from the treeview and have the corresponding node in the database, plus any children, be deleted. I tried this:
private void CascadeDelete(int iParent)
{
    DataView dvView = new DataView(dsData.Tables[0]);
    dvView.RowFilter = "ParentID = '" + iParent + "'";		

    while (dvView.Count>0)
    {
        DataRowView thisRow = dvView[0];
        int thisID = Int32.Parse(thisRow["TypeID"].ToString());
        CascadeDelete(thisID);
        //dvView = new DataView(dsData.Tables[0]);
        //dvView.RowFilter = "ParentID = '" + iParent + "'";
        MessageBox.Show("DELETING: " + thisRow["strType"].ToString());
        thisRow.Delete();
	//dsData.AcceptChanges();
    }
}

The problem, I think, is that as the recursion unwinds the DataRowView of the caller is out of date because the callee has changed it, but trying to update it again (by uncommenting the above lines) doesn't seem to work. The end result is that when I try to call dsData.GetChanges() it returns null.

Here's a example of the messed up recursion, give the nodes:
1
|-3
|-2
  |-6
  |-5
  | |-7
  4


I get this series of "deletion": 3,6,7,7,5,4,6,5,4,2,3,2
Any ideas on an efficient (or even just working!) way to do this? I could just issue a bunch of individual SQL statements to delete each row, but that seems horribly inefficient.

Thanks
GeneralRe: Cascading delete in a self-joined table Pin
Daniel Turini10-Oct-02 10:45
Daniel Turini10-Oct-02 10:45 
GeneralRe: Cascading delete in a self-joined table Pin
Wjousts11-Oct-02 3:16
Wjousts11-Oct-02 3:16 
GeneralBulk Insert (ADO/Access2000) Pin
ssirisha10-Oct-02 9:56
ssirisha10-Oct-02 9:56 
GeneralRe: Bulk Insert (ADO/Access2000) Pin
Mazdak10-Oct-02 22:02
Mazdak10-Oct-02 22:02 
GeneralRe: Bulk Insert (ADO/Access2000) Pin
ssirisha11-Oct-02 2:01
ssirisha11-Oct-02 2:01 
GeneralDisplay Row Number Pin
Jason Weibel10-Oct-02 9:30
Jason Weibel10-Oct-02 9:30 
GeneralRe: Display Row Number Pin
Michael P Butler10-Oct-02 9:58
Michael P Butler10-Oct-02 9:58 
GeneralRe: Display Row Number Pin
Jason Weibel10-Oct-02 10:03
Jason Weibel10-Oct-02 10:03 
GeneralRe: Display Row Number Pin
Robby10-Oct-02 10:35
Robby10-Oct-02 10:35 
GeneralRe: Display Row Number Pin
Carlos Antollini10-Oct-02 10:44
Carlos Antollini10-Oct-02 10:44 
GeneralRe: Display Row Number Pin
Rein Hillmann14-Oct-02 22:30
Rein Hillmann14-Oct-02 22:30 
GeneralRe: Display Row Number Pin
Rein Hillmann14-Oct-02 22:50
Rein Hillmann14-Oct-02 22:50 
QuestionCan I SELECT information the same time i INSERT Pin
Robby10-Oct-02 9:04
Robby10-Oct-02 9:04 
AnswerRe: Can I SELECT information the same time i INSERT Pin
David Salter10-Oct-02 9:56
David Salter10-Oct-02 9:56 
AnswerRe: Can I SELECT information the same time i INSERT Pin
Jon Hulatt10-Oct-02 22:05
Jon Hulatt10-Oct-02 22:05 
GeneralADO Command->Execute throws exception Pin
ssirisha10-Oct-02 5:55
ssirisha10-Oct-02 5:55 
GeneralRe: ADO Command->Execute throws exception Pin
Carlos Antollini10-Oct-02 6:22
Carlos Antollini10-Oct-02 6:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.