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??
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 > 0)
MessageBox.Show("Record Added");
else
MessageBox.Show("Not Added");
try
{
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
where the remain code of insertion is in a separate class:
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;
}
}
thanks a lot