Last post Apr 27, 2009 04:22 AM by Samu Zhang - MSFT
Apr 20, 2009 01:58 PM|hpjack433|LINK
I have a scenario where i need to save the textbox values into xml and then save that xml into sql server 2005.
I will try to give you an example here.....i have a webpage which has got all textboxes and a save button. The moment a user enters the values in those textboxes and clicks on the save button, the values in the textboxes should be saved as XML and then the
XML should be saved in SQL server 2005. So here two things should happen.
1) values in the textboxes should be saved into XML
2) XML should be saved into SQL Server
I have gone through few website links, but didn't get much help. I thought, this is the right forum which could help me out. I really need your input guys.....if possible, if you could give me a sample code, i would be more than happy.
Would be eagerly and desparately waiting for your replies as soon as possible
asp .net and xml
XML and XmlDataSource Control
Apr 20, 2009 02:56 PM|rtpHarry|LINK
Apr 20, 2009 02:57 PM|jnsuryaprakash|LINK
Here is a code snippet very close to what you are looking, you might have to do some modification basing on your table structure
Apr 20, 2009 03:26 PM|hpjack433|LINK
thanks a lot for your reply....the code snippet is used only to save the xml file into sql server....but how about saving the textbox values in the asp.net webpage in the form of an xml file.......actually i am a newbie in asp.net and c#....
Apr 23, 2009 10:48 AM|hpjack433|LINK
still waiting for your answers dear members....
I have to save the textbox values into xml (when you click on the save buttton).....
its really urgent....
eagerly waiting for your responses
Apr 23, 2009 06:49 PM|rtpHarry|LINK
Tell you what, post up the page you want to turn into xml and I will guide you some more.
I dont think there is a way to directly turn textboxes into xml (not a nice one anyway).
You would have to do the following
Now, there is a lot of jargon in there that might make this seem like a big task but to be honest you just setup the plumbing and connect the dots. The really complicated work is all handled for you.
Apr 24, 2009 12:52 AM|Devaang|LINK
Hi check the insert method of following post.
Apr 27, 2009 04:22 AM|Samu Zhang - MSFT|LINK
Hi hpjack433 ,
SQL Server 2005 will feature a native XML data type that will allow you to store native XML data in SQL Server itself. And you can use Ado.net technology to insert xml data to db.
using (SqlConnection conn = new SqlConnection(connString))
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "Insert XmlTest(ID, XmlDesc)
//Set value of parameters
SqlParameter firstColParameter =
firstColParameter.Value = ID;
SqlParameter secondColParameter =
secondColParameter.Value = new SqlXml(new
XmlTextReader(xmlValue, XmlNodeType.Document, null));
//Execute update and close connection
You can instence an object of Class SqlXml, supplying the XML value from the supplied
Stream-derived instance. And the stream-derived instance can be a in-memory stream instance, such as MemoryStream:
You can use xmldocument to create xml content and save it to memorystream:
MemoryStream streamSave = new MemoryStream();
XmlDocument doc = new XmlDocument();
streamLoad.Position = 0;
// create a SqlXml here...