Delete Row (XML) Compiler Error

  • Thread starter Thread starter Aaron
  • Start date Start date
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
 
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]);
 
Back
Top