.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Get XML Data in datagridview from SQL SERVER Table

Posted By: Manju     Posted Date: March 09, 2009    Points:2   Category :C#
How to get Data from SQL Server Table having column as of XML Type in a datagridview.
Help me in Doing This

Author: Rahul             
Posted Date: March 09, 2009     Points: 5   

the easy way is load the XML string into DataSet by using ReadXML() Method. and bind the dataset to data grid.


DataSet ds = new DataSet();
DataGridView1.DataSource = ds;

Hope this helps

Author: Manju             
Posted Date: March 09, 2009     Points: 5   

But the XMl data is in sqlserver table in fact in a column.Then wat to do

Author: Rahul             
Posted Date: March 09, 2009     Points: 5   

Hi Maju,
Than try like this

1) get the string from the column by dataset or datareader

2) store the column value in a string variable eg

string str = ds.Tables[0].Rows[0]["ColummnName"].ToString();

3) after getting the string in the variable by step 2 use this code

DataSet ds = new DataSet();
ds.ReadXml(str); //pass the xml string
DataGridView1.DataSource = ds;

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend