.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

for xml explicit

Posted By:      Posted Date: September 06, 2010    Points: 0   Category :Sql Server
Hi, I'm using FOR XML EXPLICIT to generate xml file from sql 2000 database... I need to generate something like this: <PRICE currency="EUR">150.45</PRICE>   How can I do this if I have a table Product with column Price?

View Complete Post

More Related Resource Links

Automatic vs Explicit Properties

If the reason that motivated the change from automatically implemented property to explicitly implemented property was to change the semantics of the property then you should evaluate whether the desired semantics when accessing the property from within the class are identical to or different from the desired semantics when accessing the property from outside the class.

INotifyPropertyChanged, explicit interface implementation and binding

Hello. Can I notify about explicitly implemented property change and what name should I provide to PropertyChanged? Or does WPF support onetime binding only for them?

Small problem with FOR XML EXPLICIT

Hello everyone, For my BizTalk application I need to receive "STRUCTURED" XML from SQL Server so I decided to use FOR XML EXPLICIT.  I have a pretty simple scenario. I have 2 tables in SQL. One is a table for invoices, the other one a table for items. One invoice can have many items. I use a stored procedure to retrieve invoices. Right now the returned XML only retrieves the items for the last invoice. So if the SP returns 3 invoices, the first 2 will only have the receipt number and supplierIdCompany and the last record will be complete with the items (as expected). My SP is as follows ALTER PROCEDURE [dbo].[RetrieveDeliveryreceipts] AS BEGIN SET NOCOUNT ON;     -- Insert statements for procedure here  SELECT 1 AS TAG, NULL AS PARENT,  tblDeliveryReceipts.dlrReceiptNumber AS [tblDeliveryReceipts!1!ReceiptNumber!ELEMENT],  tblDeliveryReceipts.dlrSupplierIdCompany AS [tblDeliveryReceipts!1!SupplierIdCompany!ELEMENT],  NULL AS [tblDeliveryReceiptLines!2!ItemDescription!ELEMENT],  NULL AS [tblDeliveryReceiptLines!2!Quantity!ELEMENT]  FROM tblDeliveryReceipts   WHERE tblDeliveryReceipts.dlrReceiptNumber = 'B 00000010' OR tblDeliveryReceipts.dlrReceiptNumber = 'B 00000011' OR tblDeliveryReceipts.dlrReceiptNumber = 'B 00000012'  UNION ALL  SELECT 2 AS TAG, 1 AS PARENT,  tblDeliveryRec

For XML Auto & Explicit

HI,I wrote a query in SQL Server Management Studio Express,Select * from Categories FOR XML AUTO <Categories ID="1"  ..... /><Categories ID="2"  ..... />The query generated a XML document and on the second row (when I highlight) it showing 'XML document cannot contain mutiple root level elements'. Is this okay?Select * from Categories FOR XML EXPLICITError: FOR XML EXPLICIT requires the second column to hold NULL or nonnegative integers that represent XML parent tag IDs. How to clear this error?

using UpdateSourceTrigger=Explicit with GetBindingExpression() on class objects with inherited



I have a class that inherits from FrameworkElement and has a mixture of DPs that I've added and the ones inherited e.g. WidthProperty, HeightProperty etc...

I have a UserControl that inherits from my class and has various textboxes in a popup resource like this

<TextBox Text="{Binding Path=Width, UpdateSourceTrigger=Explicit}" />

I've added a click button so that when the user changes one of the textboxes (in the popup), a routedUIcommand will fire (see below).


 public static void OkCommand_Executed(object sender, RoutedEventArgs e)
      MyClass c = (MyClass)sender;

//this seems to work fine because it is implicitly declared in my class
      BindingExpression be = s.GetBindingExpression(MyClass.MyPropertyProperty);
      if (be != null) be.UpdateSource();

//this does not work because the DP is inherited from FrameworkElement. It is returning null.
      BindingExpression be = s.GetBindingExpression(MyClass.WidthProperty);
      if (be != 

Explicit Expression Aliasing in SQL Queries


Due to restrictions on implicit column alias usage in SQL queries (only in ORDER BY), Emtucifor (Erik) suggested the idea of explicit expression aliasing. I like the approach because it makes the query easier to read and increases the SQL developer productivity. What do you think?

Example query for explicit expression aliasing:

  SUM (H.TotalDue) TotalSales
FROM AdventureWorks2008.Sales.SalesOrderHeader H
  YEAR (H.OrderDate) AS [Year],
  MONTH (H.OrderDate) AS [Month]
WHERE [Year] > 2002
GROUP BY [Year], [Month]
ORDER BY [Year], [Month]

This thread is a spin-off from: http://social.msdn.microsoft.com/Forums/en/transactsql/thread/4ad14cad-1e61-43a0-96f8-70a506106a00


Kalman Toth, SQL Server & Bu

IPCChannel explicit clean-up?



I create an IPCChannel on the server and register a singleton with it.  My client creates an instance of this remote object for communication purposes.  If the server process is restarted, my client can detect this and will try to re-activate the remote object.  It seems that if this disconnect/connect to the server happens to quickly, the client will receive a RemotingException indicating "Access Denied".  This leads me to believe that cleanup of the named pipe needs to be done when the service shuts down, to ensure it is available immediately upon restart.  However, to accomplish this I've tried IPCChannel.StopListening(null), ChannelServices.UnregisterChannel(serverChannel), and also setting the remote object to null on the client -- all to no avail.


I found a newsgroup article where folks report identical behavior with no resolution: http://groups.google.com/group/microsoft.public.dotnet.framework.re

use of foreach with explicit interface implementation?


Hi, so on msdn page


They say


The disadvantage of omitting IEnumerable and IEnumerator [in C#] is that the collection class is no longer interoperable with the foreach statements, or equivalents, of other common language runtime-compatible languages.

You can have the best of both worlds, type-safety within C# and interoperability with other common language runtime-compatible languages, by inheriting from IEnumerable and IEnumerator and using explicit interface implementation as demonstrated in the following example.



But the example they show right beneath that, does it actually contain any explicit

Dynamic Explicit Casting


I have the following C# code in a method of a class that inherits from Image. Basically I'm setting a random left margin (within some parameters) relative to its container (a Grid object).

int auxLeftMargin = rand.Next(Convert.ToInt32( ((Grid)Parent).ActualWidth / 4), Convert.ToInt32(((Grid)Parent).ActualWidth - ((Grid)Parent).ActualWidth / 6));

Margin = new Thickness(auxLeftMargin, Margin.Top, Margin.Right, Margin.Bottom);

I've changed the container type a couple of times already, so I would like to be able to not have it hardcoded. I've tried casting with "( Parent.GetType() )" but it doesn't work.

Is there a way to do this dynamically? Thanks.

Good process to pass an explicit prefiltering to a sub report



I try to pass my parameter CRM_FilteredSystemUser from my main report to the sub report.

So it's working fine in the main report. And it's working fine as parameter entered by myself testing straight in the subreport.

But I don't know how to set this parameter in the subreport to make this work.


In my main report I pass the CRM_FilteredSystemUser =Fields!systemuserid.Value to the sub report.

My main report has as report parameters : CRM_FilteredSystemUser, Non-queried : SELECT systemuserid,eu_securityrole, eu_reporthubname, fullname, businessunitidname FROM FilteredSystemUser

I'm using as well this parameter in my subreport : ...SELECT  businessunitidname,  EU_attendanceentry.*
FROM EU_attendanceentry INNER JOIN  ('+@CRM_FilteredSystemUser+') ....

In my subreport I've a report parameter :  CRM_FilteredSystemUser / Non-queried : =Parameters!CRM_FilteredSystemUser.Value

But doint that I've the error: An error occurred while executing the subreport ‘subreport1’: The definition of the report '/Calls per field Day_SubReport' is invalid.


I'm very confused there,

Explicit SSL connection in C#


Hi All,

   Can anyone help me do explicit FTPs (SSL) connection in c#? Specifically, file uploads.

   I am currently using FtpWebRequest. Everything works fine until I enabled SSL via FtpWebRequest.Enabledssl property.  

   During testing of the module i'm developing, I've encountered an unhandled exception indicating,

   "System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The token supplied to the function is invalid"


I've searched the net and found several posts related to this. Found out that implicit SSL connection is not supported by FtpWebRequest (http://dayamn.com/2010/03/ftpwebrequest-with-implicit-ssl-not-possible/).  Hence, I wanted to go to exlplicit FTPs/SSL connection. 

Any opinions on using Projection or explicit join syntax when joining entities in Linq to SQL?



I would like to know whether people use the join syntax OR projection when joining entities in LINQ to SQL queries. I have noticed that when using projection that a CROSS JOIN is in the generated SQL


var query =
from o in Orders
from  oi in o.OrderItems
where oi.OrderId == o.OrderId

generates SQL something like...

FROM [Customer].[Orders] AS [t0]
CROSS JOIN [Customer].[OrderItems] AS [t1]
WHERE ([t1].[OrderId] = [t0].[OrderId]) AND ([t1].[OrderId] = [t0].[OrderId])

whereas with explicit joins I get a clean inner join..

var query =
from o in Orders
join oi in OrderItems on o.OrderId equals oi.OrderId


FROM [Customer].[Orders] AS [t0]
INNER JOIN [Customer].[OrderItems] AS [t1] ON [t0].[OrderId] = [t1].[OrderId] 

I know using explicit joins over projection is frowned upon, but I am wary of those cross joins.

Just wondering what other folks preferences are when using joins in L2SQL.





Explicit Login and BUILTIN\Administrators question


I have a single instance of SQL Server 2005 Std SP3 running on a W2003 Server std SP2 called SRVBIZ.


I have a windows domain admin account named  ROB\business.


On SRVBIZ, ROB\business is a member of the Administrators group.


In SQL Server, The BUILTIN\Administators group login is enabled is granted permission to connect to the database engine. So ROB\business is a member of this group.


In SQL Server, ROB\business also has it's own explicit login and has dbo permissions on DB1


I now deny permission to connect to the database engine for the BUILTIN\Administrators group.


Creating XML file from SQL Query Using FOR XML EXPLICIT


Hi there

I am wanting to create an XML file from data within a database. 

I have successfully done this using "XmlTextWriter" class.

I now have a sql query outputting performatted xml data and want to "inject" this into the XmlTextWriter rather than interate through a dataset and write the individual nodes.

My code is:

XmlTextWriter writer = new XmlTextWriter("d:/MyXMLFile.xml", Encoding.UTF8);
writer.Formatting = Formatting.Indented;
writer.WriteAttributeString("id", "-1");
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend