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

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

returning data from xmlQuery

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :Sql Server

I have a table with 2 columns, first column called ObjectID - GUID field with Primary INdex, then a field called xmlData that is XML data type.

I want to get all ObjectIDs where certain xpath criteria matches the data in the xmlData field

here's what I have so far for the query, but it keeps returning data even if the xPath does not match



ObjectID, xmlData.query('

for $data in //xml/data

where $data/@value < "5"

return $data'

View Complete Post

More Related Resource Links

Entity Data Model and database view returning the same columns as there are in a table


When adding a stored procedure into the Entity Data Model I can select whether the procedure returns a scalar, a (new) complex type or one of the entity types I already defined. 

How do I do something similar for a view?

I mean assuming I have a view like this

CREATE VIEW FilteredFoos as SELECT Foo.* FROM Foo join ... WHERE ...

(that is a view that implements some involved filtering, but returns all columns from one table) how do I add it to the project so that I can use the entity set, but get the Foo objects, not some new FilteredFoo objects.

var foos = myDB.FilteredFoos.Include("Bar").ToList();

foreach (Foo foo in foos) { ...

Thanks, Jenda

Returning last 4 digits of an ssn populated by dirty data

I have an ssn column that some times has a valid 9 digit ssn, sometimes has format characters, sometimes has "garbage" (including less that 4 characters as it is a test database), null, etc. I would like to write a substring statement that will return the last 4 digits of the ssn if it is valid. What would be the best way to do that in t-sql?

returning data as hyperlink works but doesn't work


Please help. I have a form that searches my database and returns results well but each record contains a cell with a link to another html page. The problem is that whether I place the html pages in the same directory as the .asp codes or in a separate directory with the link being an absolute URL, the action of clicking on the link fails to redirect. Is it possible?

The returns are addresses and the link in each record is to it's own address page with google map.

TCPClient and Read not returning complete data unless I use thread.sleep


Hello experts, here is my code that I have a question on:

 Dim receivedbyte(1024) As Byte
        Dim myread As Integer = 0
        Dim myresponsesb As New StringBuilder()
            myread = myns.Read(receivedbyte, 0, receivedbyte.Length)
            myresponsesb.Append(System.Text.Encoding.UTF8.GetString(receivedbyte, 0, myread))

        Loop While (myns.DataAvailable)

In the above, myns is a networkstream that is initialized with a tcpclient that is communicating with a XMPP server. basically, iam getting back xml messages.

The issue with the above is that if I dont use thread.sleep(500), the complete data is not returned. Why is that? I have tried to use a streamreader instead of read and using that method i can get complete data from the stream. What am I doing wrong with the Read method of networkstream?

SECOND: The XML being returned from the server is not well formed - the closing tag for one of the tags is missing and I am unable to use XDocument to parse this XML because of this. What could be the issue here? Is it my code or something on server end?

Also, what technique should i use to make the returned XML well formed so that I can use XDOCUMENT and LINQ to parse this?


Select * query not returning all data in a row.


I am using SQL Server 2008 and am new to databases so this may be an obvious one to others.  I have setup a database and have 2 rows in a table which I am trying to read.  If I write a query in SQL Server it works fine, but the exact same query via ODBC connection only returns some of the of data in the affected rows.   The data not being returned is rather large (text field +1000 characters) but even if I create a row with just 1,2,3,4, (one in each column) it still only returns some of the data. 

SELECT * FROM [database].[dbo].[table] WHERE [station_name] = 'XXXXX'

Expected return XXXXX 1 3 5 10-11-2010  (where XXXXX is station name from above)

Actual return XXXXX (null) (null) 5 10-11-2010

The server the database resides on is administrated by IT so I have no idea what settings it has.  I had everything running in a MySQL database and my boss wanted it in MSSQL on the new server so I am trying to convert. This is the last thing that doesn't work.

Returning Data from Inheritance


Hey guys,

I've got an entity that inherits from another, but for some reason the entity that is inheriting isn't showing as an available object?

The parent entity is "Customer" and the child entity is called "RetailCustomer", but only 
"Customer" will show in intellisense as being available?

I'm currently using:

Dim DGEntities As New DecoGlazeEntities

    Function customerQuery() As IEnumerable

        Dim Result = From c In DGEntities.Customers Where c.Id = CustomerId Select c

        Return Result

    End Function

And really need to be using something like this...

Dim DGEntities As New DecoGlazeEntities

    Function customerQuery() As IEnumerable

        Dim Result = From c In DGEntities.RetailCustomers Where c.Id = CustomerId Select c

        Return Result

    End Function

... but VS comes back telling me that RetailCustomers isn't a member of my Entities Context.

Any help would be appricated!


Error returning a data table

  1. public DataTable ExcelToDatatable_dt1  
  2.        &

Data List Returning Incomplete Results


Hi All

I have a page where users can search by company name, the data list is pulled from an Excel spreadsheet hosted on the site.  I'm seeing some strange results returned, for example:

In the company field say there are the following entries:

Anns Company
Bernards Business
Company B
Dermots Domain
Property Company

If I search for "Com" I get the following returns (correct):

Anns Company
Company B
Property Company

If I search for "Der" I get my "Sorry there are no matching results" message (Incorrect)

If I search for "Ann" I get the following returns (Correct):

Anns Company

And if I search for "e" I get the following returns (Correct):

Bernards Business
Dermots Domain
Property Company

It seems random as to why it doesn't return some values, I've tried moving rows around to see if that's the problem but it makes no difference.  My range is set correctly in the spreadsheet.

When I debug the VB code behind, when I search for something that works correctly e.g. "Com" in the above example, once enter the value and click search Visual Studio begins steping into

Problems with returning the data table


public DataTable ExcelToDatatable_dt1
                foreach (GridViewRow rowItem in GridView1.Rows)

JQuery getJSON call to MVC Controller not returning data


This is probably something simple. The following JQuery call is executing can calling the controller and the controller is executing correctly. I used the sample data that's commented out to verify that the templates were working also.

However, the success function is not executing in the browser. Any thoughts or other ways I can debug this?

<script type="text/javascript">
@* var myData = [ {first: "Jane", last: "Doe"}, {first: "John", last: "Doe"} ]; *@

Send Activity not receiving data and not returning data


I am invoking a WCF Service using Send Activity from a WF Service. The target WCF Service is getting called but the inputs and outputs are null. Have defined inputs and outputs of the target WCF Service as MessageContracts. For the input,  have set the IsWrapped to false and for the output have set IsWrapped to true.

I dont receive any error either during WF Service execution or during the target WCF Service execution. From the Debug mode I have checked that : All the four activities Receive, Send, Receive Reply, Send Reply are executing without errors. Data received inside Send is null and data received from Recieve Reply is also null.

Please help.


Returning Data based on Logged on User



I've looked through many of similar threads and i'm still unable to get what i require to work. So decided i would request the help of you guys :o).

Firstly im a newbie on ASP and the code might look shocking.

What im trying to do is return data from (Table1) where the logged in userid = the Userid in (table1). I am using the ASPNET membership logins.

Depending on what i change i get diffrent errors.

"Conversion failed when converting from a character string to uniqueidentifier. "

ASPX File Below

<form runat="server">Welcome back
<asp:LoginName ID="LoginName1" runat="server" />
, Please see below.
<br />
<br />

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        <asp:BoundField DataField="Skill" HeaderText="Skill" 
            SortExpression="Skill" />
        <asp:CheckBoxField DataField="Shared" HeaderText="Shared" 
            SortExpression="Shared" />
        <asp:BoundField DataField="TimeFrame" HeaderText="TimeFrame" 
            SortExpression="TimeFrame" />
        <asp:BoundField DataField="MethodText" HeaderText="MethodText" 
            SortExpression="MethodText" />
        <asp:BoundField DataField="guid" HeaderText="guid" SortExpression="guid" 

Creating webservices for returning the Xml Data


Hi All,


 I am developing simple webservice need to display the information in  xm format like









how can i achieve this please any one send me usefull link



Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

Surrogate vs Natural Primary Keys - Data Modeling Mistake 2 of 10

In case you're new to the series I've compiled a list of ten data modeling mistakes that I see over and over that I'm tackling one by one. I'll be speaking about these topics at the upcoming IASA conference in October, so I'm hoping to generate some discussion to at least confirm I have well founded arguments.

The last post in this series Referential Integrity was probably less controversial than this one. After all, who can argue against enforcing referential integrity? But as obvious as surrogate keys may be to some, there is a good deal of diversity of opinion as evidenced by the fact that people continue to not use them.

Editing the Data in a GridView

In addition to deleting a GridView's underlying data, another common need is to allow end users to edit the data displayed in a GridView. With ASP.NET 1.x's DataGrid control, editing the data is certainly possible, but requires creating three event handlers and writing a dozen or so lines of code. With the GridView and ASP.NET 2.0, it is possible to create an editable GridView without writing a single line of code! All of the necessary functionality is encapsulated within the GridView.

The GridView allows editing on a row-by-row basis. An editable GridView contains an additional column with an Edit button in each row. When the end user clicks on an Edit button that row becomes editable, causing the Edit button to change to Update and Cancel buttons and the other columns to become TextBoxes. The end user can then update one or more column values and click Update to save their changes.

Using ASP.NET 3.5's ListView and DataPager Controls: Displaying Data with the ListView

Prior to ASP.NET 3.5, developers who needed to display a set of records could choose between the GridView, DataList, and Repeater controls. The GridView provides rich data features, but has a very boxy layout; the DataList and Repeater allow for a more flexible layout, but lack the "point and click" data features found in the GridView, DetailsView, and FormView controls. The ListView bridges the gap between layout flexibility and built-in data features.

This article, the first in a series of articles on the ListView and DataPager controls, looks at the ListView's many available templates and illustrates how to display data. Read on to learn more!
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