I have connected my C# winforms app to SQL Server 2005 where is a column of XML data type.
The C# program is performing the ADD, DELETE, UPDATE and SELECT queries properly,
now the next step is to get the xml which is stored in the database through query in a string which I did successfully and showed in MessageBox,
My problem is that I want the attributes of the xml and values show in the GridView while ignoring the other tags, please help me with running source code cause just refering to the functions doesn’t work. thanks…. suppose I execute reader.read(); whats next?
private void button2_Click(object sender, EventArgs e)
{
try
{
// setData();
qry = "select ID , Name from xmlTB";
reader = db.select_data(qry);
while (reader.Read())
{
MessageBox.Show((reader[0].ToString() +reader[1].ToString()));
}
}
catch (Exception ex)
{ }
}
database connections are in different class but don’t worry everything is working just need next step please
You need to select specific values only. Use LINQ-to-XML to extract the needed values from the XML you have.
You can use XDocument.Parse to transform the raw data to a query-able object.
For example: