Solved

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

Posted on 2010-11-12
4
337 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

14 Experts available now in Live!

Get 1:1 Help Now