Click here to Skip to main content
15,915,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
var ee = TxtID.Text + TxtName.Text+ DdlCity.SelectedItem.Text;

cmd = new SqlCommand("XmlDataModifications", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@XMLdata", SqlDbType.Xml);
cmd.Parameters["@XMLdata"].Value = ee;

con.Open();

cmd.ExecuteNonQuery();

con.Close();

i'm using tz to pass data into XML field but it is storing as normal data

For example var ee contains "74ushahyderabad" the same as it is storing in sql xml datatype field.

what can i have to store it as xml data.
Posted
Updated 1-Dec-16 2:50am
v2

I find a solution here it is
C#
XDocument doc = new XDocument();
XElement ele = new XElement("Element", new XElement("ID", TxtID.Text), new XElement("Name", TxtName.Text), new XElement("City", DdlCity.SelectedItem.Text));

cmd = new SqlCommand("XmlDataModifications", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@XMLdata", SqlDbType.Xml);
cmd.Parameters["@XMLdata"].Value = ele.ToString();

con.Open();

cmd.ExecuteNonQuery();

con.Close();
 
Share this answer
 
v2
 
Share this answer
 
Comments
Dave Kreskowiak 1-Dec-16 10:47am    
Really? Dropping an answer on a TWO AND A HALF YEAR OLD question that was already answered is considered rude.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900