title: How to retrieve xml from SQL Server 2005 in C#?
body: <p>I have inserted xml into SQL Server 2005 through rich text field successfully,
  now what I want to do is retrieve the xml from the DB but values separately and schema seperate... how can i do that in my existing code??</p>
  
  <pre><code>public void setData()
  {
     dc.ID = textBox1.Text;
     dc.Name = richTextBox1.Text;
  }
  
  private void button1_Click(object sender, EventArgs e)
  {
      setData();
  
      int flag = db.InsertData("insert into xmlTB values('" + dc.ID + "','" + dc.Name + "')");
      if (flag &gt; 0)
         MessageBox.Show("Record Added");
      else
         MessageBox.Show("Not Added");
  
      try
      {
      }
      catch (Exception ex) 
      {
          MessageBox.Show(ex.Message);
      }
  }
  </code></pre>
  
  <p>where the remain code of insertion is in a separate class:</p>
  
  <pre><code>public SqlConnection conn = new SqlConnection("Data Source=SERVER1\\SQLEXPRESS;Initial Catalog=xml;Integrated Security=True;Pooling=False");
  
  public int flag = 0;
  public SqlDataReader sdr = null;
  public DBConnection() { } // constructor
  
  public int InsertData(string qry)
  {
       try
       {
            conn.Open();
            SqlCommand cmd = new SqlCommand(qry, conn);
            flag = cmd.ExecuteNonQuery();
            conn.Close();
            return flag;
        }
        catch (Exception)
        {
            return flag;
        }
   }
  </code></pre>
  
  <p>thanks a lot</p>