473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

C# XML -> MSSQL Database

Hi eveyone,

Hi EveryOne,

I am having a real problem, which i am unable to resolve.
The problem is that i am tring to convert the datset using
XmlDataDocument, following is the code. My Problem is that
the while assigning the InnerXml to string variable
stream. it add escape character to my xml stream. after
the code is the example...of xml output. A help will be
really appreciated

public void PostFeedbackResponseAsDataSet(ResponseDataSet
response,Int32 feedbackMaximumResponseSize)

{

try

{

String stream = "";

XmlDataDocument xmldom = new XmlDataDocument(response);

if(xmldom.HasChildNodes)

{

<!--Problem-->stream = xmldom.FirstChild.InnerXml.ToString
(); if(stream.Length > feedbackMaximumResponseSize)

{

throw(new ArgumentException("Feedback response exceeds
maximum allowed size for this feedback"));

}

DAL.InsertResponses(stream);

}

}

catch(Exception e)

{

Utility.Logger.WriteEntry(e.Message +"\t" + csStackTrace +
e.StackTrace);

throw(e);

}

}

<comment>
<FeedbackResponse Id=\"bca3180b-6e66-47f1-9ed1-
6acdfa8c986a\"
xmlns=\"http://tempuri.org/SampleResponse.xsd\"><Question
Id=\"1\" xmlns=\"\"><Answer Id=\"1\"
Text=\"dddddddddddddd\"></Answer></Question><Question
Id=\"2\" xmlns=\"\"><Answer Id=\"3
\"></Answer></Question><Question Id=\"3\"
xmlns=\"\"><Answer Id=\"5\"></Answer></Question><Question
Id=\"4\" xmlns=\"\"><Answer Id=\"14
\"></Answer></Question><Question Id=\"5\"
xmlns=\"\"><Answer Id=\"15\"></Answer><Answer Id=\"16
\"></Answer><Answer Id=\"17\"></Answer><Answer Id=\"18
\"></Answer><Answer Id=\"19\"></Answer><Answer Id=\"20
\"></Answer><Answer Id=\"21\"></Answer><Answer Id=\"22
\"></Answer><Answer Id=\"23\"></Answer><Answer Id=\"24
\"></Answer><Answer Id=\"25
\"></Answer></Question><Question Id=\"6\"
xmlns=\"\"><Answer Id=\"26\"></Answer><Answer Id=\"27
\"></Answer><Answer Id=\"28\"></Answer><Answer Id=\"29
\"></Answer><Answer Id=\"30\"></Answer><Answer Id=\"31
\"></Answer><Answer Id=\"32
\"></Answer></Question></FeedbackResponse>
</comment>
Nov 15 '05 #1
2 5113
This is not a problem, it is the way it is supposed to work.
Search this NG for message with subject: "Unwanted Escape Codes In
String..."

"Pratik Parikh" <pr***********@inin.com> wrote in message
news:14****************************@phx.gbl...
Hi eveyone,

Hi EveryOne,

I am having a real problem, which i am unable to resolve.
The problem is that i am tring to convert the datset using
XmlDataDocument, following is the code. My Problem is that
the while assigning the InnerXml to string variable
stream. it add escape character to my xml stream. after
the code is the example...of xml output. A help will be
really appreciated

public void PostFeedbackResponseAsDataSet(ResponseDataSet
response,Int32 feedbackMaximumResponseSize)

{

try

{

String stream = "";

XmlDataDocument xmldom = new XmlDataDocument(response);

if(xmldom.HasChildNodes)

{

<!--Problem-->stream = xmldom.FirstChild.InnerXml.ToString
(); if(stream.Length > feedbackMaximumResponseSize)

{

throw(new ArgumentException("Feedback response exceeds
maximum allowed size for this feedback"));

}

DAL.InsertResponses(stream);

}

}

catch(Exception e)

{

Utility.Logger.WriteEntry(e.Message +"\t" + csStackTrace +
e.StackTrace);

throw(e);

}

}

<comment>
<FeedbackResponse Id=\"bca3180b-6e66-47f1-9ed1-
6acdfa8c986a\"
xmlns=\"http://tempuri.org/SampleResponse.xsd\"><Question
Id=\"1\" xmlns=\"\"><Answer Id=\"1\"
Text=\"dddddddddddddd\"></Answer></Question><Question
Id=\"2\" xmlns=\"\"><Answer Id=\"3
\"></Answer></Question><Question Id=\"3\"
xmlns=\"\"><Answer Id=\"5\"></Answer></Question><Question
Id=\"4\" xmlns=\"\"><Answer Id=\"14
\"></Answer></Question><Question Id=\"5\"
xmlns=\"\"><Answer Id=\"15\"></Answer><Answer Id=\"16
\"></Answer><Answer Id=\"17\"></Answer><Answer Id=\"18
\"></Answer><Answer Id=\"19\"></Answer><Answer Id=\"20
\"></Answer><Answer Id=\"21\"></Answer><Answer Id=\"22
\"></Answer><Answer Id=\"23\"></Answer><Answer Id=\"24
\"></Answer><Answer Id=\"25
\"></Answer></Question><Question Id=\"6\"
xmlns=\"\"><Answer Id=\"26\"></Answer><Answer Id=\"27
\"></Answer><Answer Id=\"28\"></Answer><Answer Id=\"29
\"></Answer><Answer Id=\"30\"></Answer><Answer Id=\"31
\"></Answer><Answer Id=\"32
\"></Answer></Question></FeedbackResponse>
</comment>

Nov 15 '05 #2
Hi Friend,

A Question :

I have following xml:
<FeedbackResponse Id="bca3180b-6e66-47f1-9ed1-6acdfa8c986a"
xmlns="http://tempuri.org/SampleResponse.xsd">
<Question Id="1" xmlns="">
<Answer Id="1" Text="dddddddddddddd">
</Answer>
</Question>
<Question Id="2" xmlns="">
<Answer Id="3"></Answer>
</Question>
<Question Id="3" xmlns="">
<Answer Id="5"></Answer>
</Question>
<Question Id="4" xmlns="">
<Answer Id="12"></Answer>
</Question>
<Question Id="5" xmlns="">
<Answer Id="15"></Answer>
<Answer Id="16"></Answer>
<Answer Id="17"></Answer>
<Answer Id="18"></Answer>
</Question>
<Question Id="6" xmlns="">
<Answer Id="26"></Answer>
<Answer Id="27"></Answer>
<Answer Id="28"></Answer>
<Answer Id="29"></Answer>
</Question>
</FeedbackResponse>

I am having hardtime setting up the path, can any one help me with it...
here si my SQL SERVER STORED PROCEDURE And also please explain how you
figure out these stuff..

<code>

ALTER PROCEDURE InsertResponses
@XML nText
AS
SET NOCOUNT ON
SET XACT_ABORT ON
DECLARE @SessionId INT
print @XML
BEGIN TRANSACTION
DECLARE @idoc INT
EXECUTE sp_xml_preparedocument @idoc OUTPUT, @XML
SELECT [Id] FROM OPENXML (@idoc,'FeedbackResponse/',1)
EXECUTE sp_xml_removedocument @idoc
COMMIT TRANSACTION
RETURN 0
</code>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Manuel | last post by:
Hello, I try to export a mssql database into a csv-file. I tried this with asp, but it doesn't work. <% Dim objConn Dim csv_path
0
by: Rookie Card | last post by:
Issue - Reformating the Dates in ASP.NET from a MSSQL Database that has <NULL> values in a SmallDateTime Field to read "Dec 8, 2000" instead of "12/8/2000 12:00:00 AM" (As you might already...
0
by: Nicolas | last post by:
please how to synchronise mssql database from db2/400 ? I whish I have my db2/400 database as master and replicate it in an mssql server 2005 for reading thanks Nicolas
9
by: Advo | last post by:
Im having major problems trying to connect to a mssql database thats hosted on our server. I've got the ip, username, password and database name, yet no matter what i try, I cant seem to...
3
bhing
by: bhing | last post by:
Ciao!!.. I am currently working with mysql database now and i am trying to get some fields in the mssql database.table.. I want to automatically add those fields to my mysql database table, or if...
7
by: ScottieFromNM | last post by:
I am trying to post values into a mssql database and having some trouble. I create a detail_id in the first query and want to pass this detail_id to several other queries to insert into several other...
1
kwaxy
by: kwaxy | last post by:
Hey Frendz, I can upload files into MS Access database, but unable to upload files to MSSQL database using ASP, can anyone help me plz ????
0
by: anjali123 | last post by:
Hi, I want to prepare crystal reports for my project. I am using the database that is inbuilt with the visual studio (MSSql Database file). I didnt know what to choose as datasource to create a...
1
by: suhad | last post by:
I develop ASP.NET website using VWD and SQLserver 2005 when I try to deploy my web site I dont know the connection string information of the server (database name ,username ,password,server name)and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.