By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,558 Members | 1,373 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,558 IT Pros & Developers. It's quick & easy.

wat is the best way to pass xml into Stored Procedure

P: n/a
Hi All,

I want to use XML technologies with SQL Server 2000 for sending master
details data from Application to SQL Server. I'm using xmldocument class for
writing data in the form of attribute centric elements. First I write data
into xmldocument (using appendchild, setattributes methods), and then I use
outerxml property to get the xml in a string variable to pass it to stored
procedure as input parameter, where I use openxml to insert this data into
corresponding tables. But I face problem after writing xmldocument in C#
(but not in VB.NET). When I see the value of string variable in Command
Window it contains attributes attached with / before quotes (") like
<Customer ID=/"ALFKI/" City =/"NY/" />
What can be done to solve this problem?
I also want to know from experienced programmers that, is this the best way
to use XML for sending data to Database ? What way should I choose, if this
is not the best way?

Regards
Swat
Mar 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Can you post some sample code? Its hard to understand how exactly you
load the XML into the SQL db.

Mar 31 '06 #2

P: n/a
Hi Swat,

This is obviously an issue concerning familiarity with C#. I'm not that
experienced, but I think that what you're doing is the right way.
What can be done to solve this problem?


Firstly, are you sure that the string you see in the command window is
:

<Customer ID=/"ALFKI/" City =/"NY/" />

and not :

<Customer ID=\"ALFKI\" City =\"NY\" /> //Note the difference is
back-slashes and forward-slashes.

I believe it would be the latter case, since the backslash is what C#
uses to escape double quotes and other special characters within
strings.

Now we can move on to the implication of those back-slashes on your
stored procedure. The answer is that there is no implication, and if
your coding is done right, those back-slashes won't cause any problem.

If you don't believe me, just try executing this line : (Debug mode)
///
Console.WriteLine("<Customer ID=\"ALFKI\" City =\"NY\" />");
\\\

The output (might) surprise you. The compiler treats it that way, but
doesn't necessarily output it that way too.

Regards,

Cerebrus.

Mar 31 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.