Solved

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

Posted on 2010-11-12
4
338 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
  • 3
4 Comments
 
LVL 12

Accepted Solution

by:
jagssidurala earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now