Delete Row (XML) Compiler Error

A

Aaron

I got this code off of a Microsoft knowledge base article which was written
in VB .NET and I translated (or tried) it into C# with only one error:

DataSet toolDS;
string xmlFileName;
xmlFileName = "\\Program Files\\Tools\\pnmd.xml";

//Delete tool by tool name
string ID = "", expr = "";
//Set search criteria
expr = "ID = '" + cmbTool.Text + "'";
//Remove row
toolDS.Tables["Tools"].Rows.Remove(toolDS.Tables["Tools"].Select(expr)(0));
//Save data
toolDS.AcceptChanges();
toolDS.WriteXml(xmlFileName);

The compiler error I get is "Method name expected" at this area (which the
compiler underlines):

toolDS.Tables["Tools"].Select(expr)

What am I doing wrong or missing...can anyone help?

Thanks
 
A

Alex Feinman [MVP]

This
toolDS.Tables["Tools"].Rows.Remove(toolDS.Tables["Tools"].Select(expr)(0));
should be
toolDS.Tables["Tools"].Rows.Remove(toolDS.Tables["Tools"].Select(expr)[0]);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top