?
Solved

Delete node in treeview and its associated row in a database table

Posted on 2010-11-12
4
Medium Priority
?
342 Views
Last Modified: 2013-12-17
Hi,

I have made this code and the purpose of it is to delete a node in the treeview
and its associated row from the table. The last part does not work.

        private void tbDelNode_Click(object sender, EventArgs e)
        {
            myDataSet.Tables["Customers"].Rows[0].Delete();  <===
            myDataAdapter.Update(myDataSet, "Tree");
        }


Only the line marked with an arrow is not right. I get the message:
Object reference not set to an instance of an object.

Who can help me that when i selec a certain node of a treeview
the treeviewnode and its associated table row will be deleted.

Peter
0
Comment
Question by:peterkiers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 12

Accepted Solution

by:
jagssidurala earned 2000 total points
ID: 34126495
There are 2 reasons to get the error mentioned.
myDataSet.Tables["Customers"].Rows[0].Delete();

1) May be myDataset is null
2) There is no table with the table name called "Customers"(Check your spelling) in myDataSet
0
 
LVL 1

Author Comment

by:peterkiers
ID: 34126518
oke:

      private void tbDelNode_Click(object sender, EventArgs e)
        {
            myDataSet.Tables["Tree"].Rows[0].Delete();  <===
            myDataAdapter.Update(myDataSet, "Tree");
        }
And now...
0
 
LVL 1

Author Comment

by:peterkiers
ID: 34126522
I have this but it deletes always the first row of the table:

        {

              myDataSet.Tables["Tree"].Rows[0].Delete();  <==================
            myDataAdapter.Update(myDataSet, "Tree");
            tvNotes.SelectedNode.Remove();
        }

Greetings, Peter Kiers
0
 
LVL 1

Author Comment

by:peterkiers
ID: 34126826
Thanks for the info
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question