﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WebForms (How do I?)  » XML Problem while using Stored Procedure</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 01:39:53 GMT</lastBuildDate><ttl>20</ttl><item><title>XML Problem while using Stored Procedure</title><link>http://forum.strataframe.net/FindPost23524.aspx</link><description>&lt;FONT color=#111111&gt;Hi Trent,&lt;/FONT&gt;&lt;P&gt;&lt;FONT color=#111111&gt;I am actually running an sql statement and getting the XML via the ms sql 2008.&amp;nbsp;Testing the&amp;nbsp;XML within the ms sql 2008, it&amp;nbsp;is just fine.&amp;nbsp;When running the below code the XML&amp;nbsp;string is broken.&amp;nbsp; I am using the BO which is&amp;nbsp;the parent of all the&amp;nbsp;tables&amp;nbsp;that are&amp;nbsp;included within the&amp;nbsp;sql statement? When I copy this line&amp;nbsp; &lt;FONT size=2&gt;&lt;FONT size=2&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#111111 size=2&gt;.ExecuteScalar(cmd)&amp;nbsp;into the Watch window&amp;nbsp;and&amp;nbsp; look&amp;nbsp;into the XML string&amp;nbsp;I am getting an error.&amp;nbsp; &lt;BR&gt;&lt;BR&gt;How can I resolve this problem?&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;BR&gt;Public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Function&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; GetXMLMenuOptions() &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; cmd &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; SqlCommand()&lt;BR&gt;cmd.CommandType = CommandType.StoredProcedure&lt;BR&gt;cmd.CommandText = &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"XML_MenuOptions"&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Return&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.ExecuteScalar(cmd)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Function&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#111111&gt;Thanks,&lt;BR&gt;&lt;BR&gt;Doron&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description><pubDate>Mon, 22 Jun 2009 07:00:20 GMT</pubDate><dc:creator>Doron Farber</dc:creator></item><item><title>RE: XML Problem while using Stored Procedure</title><link>http://forum.strataframe.net/FindPost23636.aspx</link><description>Possibly.  To be honest, I don't understand why you can't bring back more than one value at a time.  Whenever I do something like this I want to take as few trips to the server as possible...this will also make the code less complicated.&lt;br&gt;
&lt;br&gt;
So before I ever put ANYTHING into a BO, I make sure that I get my data lined out.  This generally means that I will open up SQL Server Management Studio and play with the query which will ultimately become a SPROC to retrieve all data sets as I want them to be exported.  Now sometimes this isn't totally possible as some massaging may need to take place once in a BO.  However, I will be far closer to my goal than otherwise.&lt;br&gt;
&lt;br&gt;
The point I was trying to make is that it seems that you could create all of your result sets and populate all of the BOs in one trip versus getting one piece of data at a time.</description><pubDate>Mon, 22 Jun 2009 07:00:20 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: XML Problem while using Stored Procedure</title><link>http://forum.strataframe.net/FindPost23634.aspx</link><description>Hi Trent,&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;[quote][b]Trent L. Taylor (06/19/2009)[/b][hr]You would be better served to retrieve all necessary result sets and values in a single query versus calling scalar methods if you are going to have very many queries. But to my knowledge there is no limitation.[/quote]&lt;/P&gt;&lt;P&gt;You mean instead of using this code: &lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;.ExecuteScalar(cmd)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;I should use&amp;nbsp;the below:&lt;BR&gt;&lt;FONT color=#0000ff&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.FillDataTable(cmd)&lt;/FONT&gt;&amp;nbsp;&lt;BR&gt;MyBO.CurrentDataTable.WriteXml("c:\OutFile.XML", XmlWriteMode.WriteSchema)&lt;/P&gt;&lt;P&gt;That means since I have fields from other tables I will need to add those properties&amp;nbsp;in that BO as well&lt;BR&gt;Is that what you meant?&lt;BR&gt;&lt;BR&gt;Thanks,&lt;/P&gt;&lt;P&gt;Doron</description><pubDate>Fri, 19 Jun 2009 14:41:47 GMT</pubDate><dc:creator>Doron Farber</dc:creator></item><item><title>RE: XML Problem while using Stored Procedure</title><link>http://forum.strataframe.net/FindPost23609.aspx</link><description>To my knowledge there is not a character limit on a scalar value.  The only limitation is that a single value is returned.  I am curious as to why you don't return more than a single value at once anyway.  You would be better served to retrieve all necessary result sets and values in a single query versus calling scalar methods if you are going to have very many queries.  But to my knowledge there is no limitation.</description><pubDate>Fri, 19 Jun 2009 08:43:01 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: XML Problem while using Stored Procedure</title><link>http://forum.strataframe.net/FindPost23552.aspx</link><description>Hi Trent,&lt;P&gt;Thanks for your reply, let me explain this better...&lt;/P&gt;&lt;P&gt;1)&lt;BR&gt;I have a stored procedure named XML_MenuOptions which returns the XML file with the correct format.&amp;nbsp; The fields Tip and Comment are NVARCHAR type and contains RTF data from an SF RTF control. Here is the SP. &lt;/P&gt;&lt;P&gt;SELECT &lt;BR&gt;&amp;nbsp;dbo.ServiceOptions.ServiceOption,&lt;BR&gt;&amp;nbsp;dbo.ServiceOptions.DisplayOptionOrder,&lt;BR&gt;&amp;nbsp;dbo.SearchOptions.SearchOption ,&lt;BR&gt;&amp;nbsp;dbo.SearchOptions.DisplayOptionOrder,&lt;BR&gt;&amp;nbsp;dbo.SearchCategories.SearchCategory,&lt;BR&gt;&amp;nbsp;dbo.SearchCategories.DisplayOptionOrder,&lt;BR&gt;&amp;nbsp;dbo.SearchCategories.Comment,&lt;BR&gt;&amp;nbsp;dbo.SearchCategories.Tip&amp;nbsp; &lt;BR&gt;FROM &lt;BR&gt;&amp;nbsp;dbo.ServiceOptions &lt;BR&gt;&amp;nbsp;&amp;nbsp;INNER JOIN dbo.SearchOptions&amp;nbsp;&lt;BR&gt;&amp;nbsp;ON dbo.ServiceOptions.ServiceOptions_PK=dbo.SearchOptions.ServiceOptions_FK&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;INNER JOIN dbo.SearchCategories &lt;BR&gt;&amp;nbsp;ON dbo.SearchOptions.SearchOptions_PK = dbo.SearchCategories.SearchOptions_FK&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;ORDER BY dbo.ServiceOptions.DisplayOptionOrder,dbo.SearchOptions.DisplayOptionOrder,dbo.SearchCategories.DisplayOptionOrder&lt;BR&gt;FOR XML AUTO , ROOT('services')&lt;/P&gt;&lt;P&gt;2)&lt;BR&gt;I created an Scalar function in a BO (see code below) to execute the SP and returns the XML file from as string.&amp;nbsp; I noticed the following when executing the scalar function: &lt;BR&gt;&amp;nbsp;a) If the RTF fields "Tip and Comment" are included, then the string returned is not completed rendering the XML file invalid.&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;BR&gt;[codesnippet]Public Function GetXMLMenuOptions() As String&lt;BR&gt;Dim cmd As New SqlCommand()&lt;BR&gt;cmd.CommandType = CommandType.StoredProcedure&lt;BR&gt;cmd.CommandText = "dbo.XML_MenuOptions"&lt;BR&gt;Return CType(Me.ExecuteScalar(cmd), String)&lt;BR&gt;End Function[/codesnippet]&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&amp;nbsp;b) If the RTF fields are excluded, then the string returned is completed and the XML file is OK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;c) If the RTF fields are included, and I limit the records to show using a WHERE condition, then the string returned is completed and the XML file is OK.&lt;/P&gt;&lt;P&gt;At this point, I could say that there should be a problem with the amount of characters that&amp;nbsp;can be returned by the Scalar function.&amp;nbsp; &lt;U&gt;Do you have any suggestion on this regard?&lt;/U&gt; :hehe:&lt;BR&gt;&lt;BR&gt;Thanks,&lt;BR&gt;&lt;BR&gt;Doron</description><pubDate>Wed, 17 Jun 2009 12:21:34 GMT</pubDate><dc:creator>Doron Farber</dc:creator></item><item><title>RE: XML Problem while using Stored Procedure</title><link>http://forum.strataframe.net/FindPost23535.aspx</link><description>Thanks will try it out.</description><pubDate>Wed, 17 Jun 2009 07:34:37 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: XML Problem while using Stored Procedure</title><link>http://forum.strataframe.net/FindPost23534.aspx</link><description>You have to include the schema when writing the XML file.  That should be all that is required.  Here is the code that produces that XML file:&lt;br&gt;
&lt;br&gt;
[codesnippet]loMessages.CurrentDataTable.WriteXml(lcPath &amp; "Messages_" &amp; lnCodePage.ToString() &amp; ".XML", XmlWriteMode.WriteSchema)[/codesnippet]</description><pubDate>Wed, 17 Jun 2009 07:31:27 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: XML Problem while using Stored Procedure</title><link>http://forum.strataframe.net/FindPost23533.aspx</link><description>Hi Trent,&lt;br&gt;
&lt;br&gt;
We are still having a problem here with this approach.  There are 2 fields nVarchar which are used to hold RTF data, pretty much like in the SF Messaging tool.  The problem is that if these 2 fields are included in the SQL which will return the XML file, when using the BO.ExecuteEscalar() the string returned seems to be incomplete.  My guess is that we will need to apply some sort of conversion to that string to be able to properly get the RTF data in the file.&lt;br&gt;
&lt;br&gt;
Since you are using something similar in the SF Mesaging application, is there something that needs to be done to get a proper XML file with RTF data in it?</description><pubDate>Wed, 17 Jun 2009 07:26:53 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: XML Problem while using Stored Procedure</title><link>http://forum.strataframe.net/FindPost23531.aspx</link><description>Glad you got it going! :)</description><pubDate>Wed, 17 Jun 2009 07:12:50 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: XML Problem while using Stored Procedure</title><link>http://forum.strataframe.net/FindPost23525.aspx</link><description>Hi Trent,&lt;P&gt;After looking at the code I made it work, since I removed 2 nVARCHAR(MAX) columns from the SQL statement&amp;nbsp;where it is used as an RTF. Is there any way to make it work with the nVARCHAR(MAX) data type, or any other field type that will allow me to work with RTF.&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR&gt;&lt;BR&gt;Doron</description><pubDate>Tue, 16 Jun 2009 20:05:51 GMT</pubDate><dc:creator>Doron Farber</dc:creator></item></channel></rss>