Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / March 2006

Tip: Looking for answers? Try searching our database.

wat is the best way to pass xml into Stored Procedure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SwatSoftwareDev - 24 Mar 2006 06:13 GMT
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
fundamol@hotmail.com - 31 Mar 2006 19:37 GMT
Can you post some sample code? Its hard to understand how exactly you
load the XML into the SQL db.
Cerebrus - 31 Mar 2006 23:08 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.