.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 PATH and WITH XMLNAMESPACES - how do I NOT output a Namespace Reference for some PATHs?

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :
I have an SQL Server 2005 query, that uses FOR XML PATH... to output the XML. Due to the complexity of the XML being output, I use correlated subqueries to output portions of the XML. Each subquery uses FOR XML PATH... to output composites within that 'chunk' of the XML. This works fine, i.e. the XML is output as I expect it to be/as I need it to be. We also need to use namespaces for some tags. The namespaces work as well - except that the references for the namespaces seem to be output within every composite defined within every FOR XML PATH... statement. I want the references only output within the 'top' or 'root' xml tag/composite, instead of every tag/composite defined within a PATH('...') option somewhere. Another way to say that is, I only want the Namespace references output for the PATH defined within the query itself, NOT for any PATHs defined within subqueries. An example from the query itself is: SELECT ( SELECT PhoneNumber AS '@communicationNumber', 'TELEPHONE' AS '@communicationChannelCode' FROM TableName tn3 WHERE tn3.ID = tn1.ID FOR XML PATH('communicationChannel'), TYPE ), ( SELECT FaxNumber AS '@communicationNumber', 'TELEFAX' AS '@communicationChannelCode' FROM TableName tn2 WHERE tn2.ID = tn1.ID FOR XML PATH('communicationChannel'), TYPE ), 'EN' AS 'personOrDepartme

View Complete Post

More Related Resource Links

How do I find the file path from a namespace.class name?


I'm programatically looking ito a .aspx file and getting the file class name declared in its CodeBehind. For example, when analyzing myFile.aspx I read in its Page Directive and found its CodeBehind equals "myApplication\myPage.aspx.vb". Then I use the code below:


Dim Assm As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom("myApplication\bin\myApplication.dll")
Dim ClassType As Type = Assm.GetType("myApplication\myPage.aspx.vb")
' myBaseType = "myApplication.Forms.BasePage"
Dim myBaseType As System.Type = ClassType.BaseType


Now I want to read the BaseFile (class = myApplication.Forms.BasePage). However, to read in this file, I need I need to get its full path instead of its namespace.class hiearchy. In this case, the BasePage is wrapped in a different namespace declaration thus I cannot just change the '.' to '\' in order to get the path.

How can I get the path of BasePage so I can read it? Thank you - Frank

dllimport("mapi32.dll") changes the path context of application (i.e. relative paths start pointing

I have a WPF desktop application. We use mapi32.dll to show a new outlook mail window to allow user to send an email. After user sends email / just closes the new mail window without sending email, relative path starts pointing to C:\Program Files\Microsoft Office\Office12. I have office 2007 installed.  How can I restore this relative path ?   Thanks & Regards, Nadeem Ullah

"Assembly '...' Was Not Found" When including a reference to a local namespace

I've got a WPF application with a window and a usercontrol:   Window:   <Window x:Class="UI.Windows.Main" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:UI.Windows.Documents" Title="Window1" Height="600" Width="800"> <DockPanel> <!-- Snip --> </DockPanel> </Window>     UserControl:   <UserControl x:Class="UI.Windows.Documents.MyDisplay" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml> <Grid> <!-- Snip --> </Grid> </UserControl>       Now, when I try to look at this in the designer i get an error saying Assembly 'UI' was not found.  I've searched high and low, but the internet is full of references to this being a 2005 issue and the solution is to upgrade to 2008.  I'm already using 2008 (don't even have 2005 installed on the machine), and I still get the problem.

How do you reference a Path stored as a resource?

I basically want to store a Path in XAML resources and reference the resource from other elements in XAML.  I probably need to set x:Shared="False", but I basically need to reference the path resource from another <Path /> tag. More simply, can you get one XAML element to bind to another element of the same type, rather then just binding the properties?  This time I want to do this with a Path.  I would like to store the whole Path as a resource and reference it.  I know you can store shape data using Geometry values and Styles, but I would rather just store the entire Path as a resource and reference it from a <Path/> tag.

XMLdocument check if path exists (selectnodes throws "Object reference not set to an instance of an


Normally the code below works, EXCEPT if the xpath doesnt exist, then I get the error "Object reference not set to an instance of an object." on the 2nd line

Dim sessionXML As XmlDocument = Session("XML")
If sessionXML.SelectNodes("//root/data/compare/locations/location") IsNot Nothing Then

How can I check if the xpath exists (without a try catch preferably)?

.OCX reference issue "Path/File Access Error"


Hi All,

hopefully someone has solution of this error.

i am adding reference on a .ocx file in my project.

When i tried to access the method of this file .

I get the following message "Path/File Access Error"

I tried running the following commands 'regsvr32 XYZ.ocx'.

but issue is same.

Thanks in advance

Lists Service Reference namespace doesn't have CookieContainer


I downloaded /_vit_bin/Lists.asmx?wsdl and ran the "Add Service Reference" Dialog on it (The MOSS server is behind ISA Forms-Based Authentication). The name of the reference is "ListsService".

The following code doesn't build.

ListsService.CookieContainer = new CookieContainer();

It indicates that CookieContainer isn't in the namespace.

How do I pass a cookie to the service? Am I missing a "Using" statement?

for xml path output - empty tags should be

here's tha sample code:
'alpha' _name,
'alp333' _username
for xml path(''), type),
(select ccy, acc  from #samp
for xml path(''), type)
for xml path('ccyXML'),elements
current output:
    <acc />
    <acc />

A better way to reference your wizard steps using named steps

Note: this article uses the plain vanilla but the concepts apply equally well to its popular counterpart .

By far the most common way that I see wizard steps reference in code snippets is by their index.

Making Sense of ASP.NET Paths

ASP.Net includes quite a plethora of properties to retrieve path information about the current request, control and application. There's a ton of information available about paths on the Request object, some of it appearing to overlap and some of it buried several levels down, and it can be confusing to find just the right path that you are looking for.

Comma-Delimited Output

One of the common tasks performed when retrieving data from a SQL Server database is returning the result as a comma-delimited output instead of a result set. This task can be performed by using a CURSOR selecting the column to be concatenated together. Each row returned by the CURSOR is then concatenated together into a variable separating each one by a comma.

Enterprize library 4.1 getting output parameter after adding record in db, plz guide



I need to get output parameter (flag) from db after saving record in database. I am using Microsoft Enterprise Library 4.1 for DB. I am inserting record using I Data reader.

Please guide


Virtual Path Problem


 I get the following error on last line below (working on remote host): 'E:\web\sfcascom\ls_admin/uploads/images/001.JPG' is not a valid virtual path,

Note that the slashes go in different directions

I've tried a number of things but nothing seems to work. Thanks-


Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Web.UI.WebControls

Imports System.Drawing.Imaging.ImageCodecInfo
Partial Class Protected_imageupload
    Inherits System.Web.UI.Page
    Private Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        ' Initialize variables
        Dim sSavePath As String
        Dim sThumbExtension As String
        Dim intThumbWidth As Integer
        Dim intThumbHeight As Integer
        Dim sFilename As String = ""
        ' Set constant values
        'sSavePath = "images/"
        sSavePath = Server.MapPath("~/") + "ls_admin/uploads/images/"

        sThumbExtension = "_thumb"
        intThumbWidth = 160
        intThumbHeight = 120

        ' If file field isn?t empty
        If FilUpload.PostedFile IsNot Nothing Then
            ' Check file size (mustn?t be 0)
            Dim myFile As Http

reference from menubuttons to text parts in article on the same page


Hi, I'm searching now for hours but couldn't find it.Cry

In my menu i have several buttons which (by a <a href..) should go the a part of an article that is in the same form.

Menu button : What is a database should go to the page default.aspx and in there is an article published.
A part of this article is having a piece of text about "what is a database"

Menu button: how to make a query should go to this same article in the same page but then to the part that is have the piece about the query. The next could be an example of what i'm doing:

    <li><a href="default.aspx ?????>what is a database</a></li>
    <li><a href="default.aspx ?????>what is a query</a></li>

Where my question marks are, there should be a connection to that particular piece of text.
In each article part there is an ID="text1" and the second part id="text2"

How shoudl i do that, Should i use a question mark.
Please give me some guidance how to structure the <li> statement or a pointer where I can read about it.


Type or namespace error.


A couple of days ago I started getting an unusual behavior when compiling Website projects. I have referenced class libraries added to my bin folder that are also correctely referenced in using statements in my aspx.cs code behind. When I compile, I get the 

Error 4 The type or namespace name 'CommonClassLibrary' could not be found (are you missing a using directive or an assembly reference?) C:\Dev\Fiscal_Portal\Implementation\FMS Portal Site_new\App_Code\BLL\DataTables.cs 1 7 C:\...\FMS Portal Site_new\

The type or namespace name 'CommonClassLibrary' could not be found (are you missing a using directive or an assembly reference?)

error message that would typically be received when the dll has not been added as a reference or added in a using statement.

I can eliminate the error by adding an


Inline conditional output


Is it possible to somehow output some content based upon some conditional check in Razor? If not, I hope this possibility will be added in the future. What I want to do is the following:

<option value="1" @if(ListMode == 1) { = "selected=\"true\"" }>Full list</option>

As I can't figure out a way to do this, I have to either make a helper that does it for me or write duplicate code.

Creating a user friendly alias for the website path


 Hello mates,

I am hosting my ASP.NET application on a Windows 2003 Server.

To browse to my application one has to type the path :http://serverName/applicationName

I want users to only type  applicationName on the web adress area.I believe there is something to do with alias and CNAME on DNS records that can adress this.

Any help on how to go about doing this will be highly appreciated.

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